mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-26 18:20:44 +00:00
Add API to set the URI instead of hardcoding it in the gst_launch
This commit is contained in:
parent
74543783c0
commit
cf083414f6
2 changed files with 15 additions and 4 deletions
|
@ -234,10 +234,7 @@ static void *app_function (void *userdata) {
|
||||||
/* create our own GLib Main Context, so we do not interfere with other libraries using GLib */
|
/* create our own GLib Main Context, so we do not interfere with other libraries using GLib */
|
||||||
context = g_main_context_new ();
|
context = g_main_context_new ();
|
||||||
|
|
||||||
// data->pipeline = gst_parse_launch ("filesrc location=/sdcard/Movies/sintel_trailer-480p.ogv ! oggdemux ! theoradec ! queue ! ffmpegcolorspace ! eglglessink name=vsink force_rendering_slow=1 can_create_window=0", NULL);
|
data->pipeline = gst_parse_launch ("playbin2", NULL);
|
||||||
// data->pipeline = gst_parse_launch ("videotestsrc ! ffmpegcolorspace ! video/x-raw-yuv,format=(fourcc)Y444 ! eglglessink name=vsink", NULL);
|
|
||||||
//data->pipeline = gst_parse_launch ("souphttpsrc location=http://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm ! matroskademux ! amcviddec-omxgooglevpxdecoder ! queue ! ffmpegcolorspace ! eglglessink name=vsink", NULL);
|
|
||||||
data->pipeline = gst_parse_launch ("playbin2 uri=http://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.ogv", NULL);
|
|
||||||
|
|
||||||
data->vsink = gst_bin_get_by_name (GST_BIN (data->pipeline), "vsink");
|
data->vsink = gst_bin_get_by_name (GST_BIN (data->pipeline), "vsink");
|
||||||
if (!data->vsink)
|
if (!data->vsink)
|
||||||
|
@ -315,6 +312,15 @@ void gst_native_finalize (JNIEnv* env, jobject thiz) {
|
||||||
GST_DEBUG ("Done finalizing");
|
GST_DEBUG ("Done finalizing");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gst_native_set_uri (JNIEnv* env, jobject thiz, jstring uri) {
|
||||||
|
CustomData *data = GET_CUSTOM_DATA (env, thiz, custom_data_field_id);
|
||||||
|
if (!data) return;
|
||||||
|
const jbyte *char_uri = (*env)->GetStringUTFChars (env, uri, NULL);
|
||||||
|
GST_DEBUG ("Setting URI to %s", char_uri);
|
||||||
|
g_object_set(data->pipeline, "uri", char_uri);
|
||||||
|
(*env)->ReleaseStringUTFChars (env, uri, char_uri);
|
||||||
|
}
|
||||||
|
|
||||||
void gst_native_play (JNIEnv* env, jobject thiz) {
|
void gst_native_play (JNIEnv* env, jobject thiz) {
|
||||||
CustomData *data = GET_CUSTOM_DATA (env, thiz, custom_data_field_id);
|
CustomData *data = GET_CUSTOM_DATA (env, thiz, custom_data_field_id);
|
||||||
if (!data) return;
|
if (!data) return;
|
||||||
|
@ -400,6 +406,7 @@ void gst_native_surface_finalize (JNIEnv *env, jobject thiz) {
|
||||||
static JNINativeMethod native_methods[] = {
|
static JNINativeMethod native_methods[] = {
|
||||||
{ "nativeInit", "()V", (void *) gst_native_init},
|
{ "nativeInit", "()V", (void *) gst_native_init},
|
||||||
{ "nativeFinalize", "()V", (void *) gst_native_finalize},
|
{ "nativeFinalize", "()V", (void *) gst_native_finalize},
|
||||||
|
{ "nativeSetUri", "(Ljava/lang/String;)V", (void *) gst_native_set_uri},
|
||||||
{ "nativePlay", "()V", (void *) gst_native_play},
|
{ "nativePlay", "()V", (void *) gst_native_play},
|
||||||
{ "nativePause", "()V", (void *) gst_native_pause},
|
{ "nativePause", "()V", (void *) gst_native_pause},
|
||||||
{ "nativeSetPosition", "(I)V", (void*) gst_native_set_position},
|
{ "nativeSetPosition", "(I)V", (void*) gst_native_set_position},
|
||||||
|
|
|
@ -37,6 +37,7 @@ import android.widget.Toast;
|
||||||
public class Tutorial1 extends Activity implements SurfaceHolder.Callback, OnSeekBarChangeListener {
|
public class Tutorial1 extends Activity implements SurfaceHolder.Callback, OnSeekBarChangeListener {
|
||||||
private native void nativeInit();
|
private native void nativeInit();
|
||||||
private native void nativeFinalize();
|
private native void nativeFinalize();
|
||||||
|
private native void nativeSetUri(String uri);
|
||||||
private native void nativePlay();
|
private native void nativePlay();
|
||||||
private native void nativePause();
|
private native void nativePause();
|
||||||
private native void nativeSetPosition(int milliseconds);
|
private native void nativeSetPosition(int milliseconds);
|
||||||
|
@ -50,6 +51,8 @@ public class Tutorial1 extends Activity implements SurfaceHolder.Callback, OnSee
|
||||||
private int duration;
|
private int duration;
|
||||||
|
|
||||||
private Bundle initialization_data;
|
private Bundle initialization_data;
|
||||||
|
|
||||||
|
private final String mediaUri = "http://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.ogv";
|
||||||
|
|
||||||
/* Called when the activity is first created.
|
/* Called when the activity is first created.
|
||||||
@Override */
|
@Override */
|
||||||
|
@ -117,6 +120,7 @@ public class Tutorial1 extends Activity implements SurfaceHolder.Callback, OnSee
|
||||||
|
|
||||||
/* Called from native code */
|
/* Called from native code */
|
||||||
private void onGStreamerInitialized () {
|
private void onGStreamerInitialized () {
|
||||||
|
nativeSetUri (mediaUri);
|
||||||
if (initialization_data != null) {
|
if (initialization_data != null) {
|
||||||
boolean should_play = initialization_data.getBoolean("playing");
|
boolean should_play = initialization_data.getBoolean("playing");
|
||||||
int milliseconds = initialization_data.getInt("position");
|
int milliseconds = initialization_data.getInt("position");
|
||||||
|
|
Loading…
Reference in a new issue