int main (int argc, char **argv) { SkypeMediaEngine *engine; const gchar *path = NULL; g_thread_init (NULL); g_type_init (); gst_init (&argc, &argv); engine = skype_media_engine_new (); if (engine == NULL) { g_warning ("Error creating media engine."); return 1; } g_signal_connect (engine, "new-audio-call", G_CALLBACK (new_audio_call_cb), NULL); g_signal_connect (engine, "new-video-call", G_CALLBACK (new_video_call_cb), NULL); if (argc >= 2) path = argv[1]; g_debug ("Using path: %s", path); if (!skype_media_engine_start (engine, SKYPE_MEDIA_BOTH, path)) g_warning ("Error starting media engine"); g_object_unref (engine); gst_deinit (); return 0; }
int main (int argc, char *argv[]) { App *app; int ret = EXIT_FAILURE; gchar *input_fn; if (!parse_options (&argc, argv)) return EXIT_FAILURE; /* @TODO: iterate all the input files */ input_fn = g_input_files ? g_input_files[0] : NULL; if (input_fn && !g_file_test (input_fn, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) { g_warning ("input file \"%s\" doesn't exist", input_fn); goto bail; } app = app_new (input_fn, g_output_file_name); if (!app) goto bail; print_yuv_info (app); ret = app_run (app); print_num_frame (app); app_free (app); bail: g_free (g_codec_str); g_free (g_output_file_name); g_strfreev (g_input_files); gst_deinit (); return ret; }
PlayerGst::~PlayerGst() { delete timer; cleanup(); gst_deinit(); }
MainApplication::~MainApplication() { // Deinitialize GStreamer. gst_deinit(); }
int main (int argc, char *argv[]) { GThread *input_thread; gint numbuffers = -1; gchar device[128] = { '\0' }; gchar input[128] = { '\0' }; gulong frequency = 0; GstBus *bus; /* see for input option */ int c; while (1) { static char long_options_desc[][64] = { {"Number of buffers to output before sending EOS"}, {"Device location. Common in /dev/video0"}, {"input/output (channel) to switch to"}, {"frequency to tune to (in Hz)"}, {0, 0, 0, 0} }; static struct option long_options[] = { {"numbuffers", 1, 0, 'n'}, {"device", 1, 0, 'd'}, {"input", 1, 0, 'i'}, {"frequency", 1, 0, 'f'}, {0, 0, 0, 0} }; /* getopt_long stores the option index here. */ int option_index = 0; c = getopt_long (argc, argv, "n:d:i:f:h", long_options, &option_index); /* Detect the end of the options. */ if (c == -1) { printf ("tip: use -h to see help message.\n"); break; } switch (c) { case 0: /* If this option set a flag, do nothing else now. */ if (long_options[option_index].flag != 0) break; printf ("option %s", long_options[option_index].name); if (optarg) printf (" with arg %s", optarg); printf ("\n"); break; case 'n': numbuffers = atoi (optarg); break; case 'd': strncpy (device, optarg, sizeof (device) / sizeof (device[0])); break; case 'i': strncpy (input, optarg, sizeof (input) / sizeof (input[0])); break; case 'f': frequency = atol (optarg); break; case 'h': printf ("Usage: v4l2src-test [OPTION]...\n"); for (c = 0; long_options[c].name; ++c) { printf ("-%c, --%s\r\t\t\t\t%s\n", long_options[c].val, long_options[c].name, long_options_desc[c]); } exit (0); break; case '?': /* getopt_long already printed an error message. */ printf ("Use -h to see help message.\n"); break; default: abort (); } } /* Print any remaining command line arguments (not options). */ if (optind < argc) { printf ("Use -h to see help message.\n" "non-option ARGV-elements: "); while (optind < argc) printf ("%s ", argv[optind++]); putchar ('\n'); } /* init */ gst_init (&argc, &argv); /* create elements */ if (!(pipeline = gst_pipeline_new ("my_pipeline"))) { fprintf (stderr, "error: gst_pipeline_new return NULL"); return -1; } if (!(source = gst_element_factory_make ("v4l2src", NULL))) { fprintf (stderr, "error: gst_element_factory_make (\"v4l2src\", NULL) return NULL"); return -1; } if (!(sink = gst_element_factory_make ("xvimagesink", NULL))) { fprintf (stderr, "error: gst_element_factory_make (\"xvimagesink\", NULL) return NULL"); return -1; } if (numbuffers > -1) { g_object_set (source, "num-buffers", numbuffers, NULL); } if (device[0]) { g_object_set (source, "device", device, NULL); } if (input[0]) { g_object_set (source, "input", input, NULL); } if (frequency) { g_object_set (source, "frequency", frequency, NULL); } /* you would normally check that the elements were created properly */ bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); gst_bus_add_watch (bus, my_bus_callback, NULL); /* put together a pipeline */ gst_bin_add_many (GST_BIN (pipeline), source, sink, NULL); gst_element_link_pads (source, "src", sink, "sink"); /* start the pipeline */ gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); loop = g_main_loop_new (NULL, FALSE); if (!(input_thread = g_thread_create (read_user, source, TRUE, NULL))) { fprintf (stderr, "error: g_thread_create return NULL"); return -1; } g_main_loop_run (loop); g_thread_join (input_thread); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); gst_object_unref (bus); gst_object_unref (pipeline); gst_deinit (); return 0; }
int main(int argc, char *argv[]) { GstVaapiDisplay *display; GstVaapiWindow *window; GstVaapiWindowGLX *glx_window; GstVaapiSurface *surface; GstVaapiImage *image; GstVaapiTexture *textures[2]; GstVaapiTexture *texture; GLuint texture_id; GstVaapiRectangle src_rect; GstVaapiRectangle dst_rect; guint flags = GST_VAAPI_PICTURE_STRUCTURE_FRAME; static const GstVaapiChromaType chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420; static const guint width = 320; static const guint height = 240; static const guint win_width = 640; static const guint win_height = 480; gst_init(&argc, &argv); display = gst_vaapi_display_glx_new(NULL); if (!display) g_error("could not create VA display"); surface = gst_vaapi_surface_new(display, chroma_type, width, height); if (!surface) g_error("could not create VA surface"); image = image_generate(display, GST_VAAPI_IMAGE_NV12, width, height); if (!image) g_error("could not create VA image"); if (!image_upload(image, surface)) g_error("could not upload VA image to surface"); window = gst_vaapi_window_glx_new(display, win_width, win_height); if (!window) g_error("could not create window"); glx_window = GST_VAAPI_WINDOW_GLX(window); gst_vaapi_window_show(window); if (!gst_vaapi_window_glx_make_current(glx_window)) g_error("coult not bind GL context"); g_print("#\n"); g_print("# Create texture with gst_vaapi_texture_new()\n"); g_print("#\n"); { texture = gst_vaapi_texture_new( display, GL_TEXTURE_2D, GL_RGBA, width, height ); if (!texture) g_error("could not create VA texture"); textures[0] = texture; texture_id = gst_vaapi_texture_get_id(texture); if (!gst_vaapi_texture_put_surface(texture, surface, flags)) g_error("could not transfer VA surface to texture"); if (!gst_vaapi_window_glx_put_texture(glx_window, texture, NULL, NULL)) g_error("could not render texture into the window"); } g_print("#\n"); g_print("# Create texture with gst_vaapi_texture_new_with_texture()\n"); g_print("#\n"); { const GLenum target = GL_TEXTURE_2D; const GLenum format = GL_BGRA; glEnable(target); glGenTextures(1, &texture_id); glBindTexture(target, texture_id); glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glPixelStorei(GL_UNPACK_ALIGNMENT, 4); glTexImage2D( target, 0, GL_RGBA8, width, height, 0, format, GL_UNSIGNED_BYTE, NULL ); glDisable(target); texture = gst_vaapi_texture_new_with_texture( display, texture_id, target, format ); if (!texture) g_error("could not create VA texture"); if (texture_id != gst_vaapi_texture_get_id(texture)) g_error("invalid texture id"); if (gl_get_current_texture_2d() != texture_id) g_error("gst_vaapi_texture_new_with_texture() altered texture bindings"); textures[1] = texture; if (!gst_vaapi_texture_put_surface(texture, surface, flags)) g_error("could not transfer VA surface to texture"); if (gl_get_current_texture_2d() != texture_id) g_error("gst_vaapi_texture_put_surface() altered texture bindings"); src_rect.x = 0; src_rect.y = 0; src_rect.width = width; src_rect.height = height; dst_rect.x = win_width/2; dst_rect.y = win_height/2; dst_rect.width = win_width/2; dst_rect.height = win_height/2; if (!gst_vaapi_window_glx_put_texture(glx_window, texture, &src_rect, &dst_rect)) g_error("could not render texture into the window"); if (gl_get_current_texture_2d() != texture_id) g_error("gst_vaapi_window_glx_put_texture() altered texture bindings"); } gst_vaapi_window_glx_swap_buffers(glx_window); pause(); g_object_unref(textures[0]); g_object_unref(textures[1]); glDeleteTextures(1, &texture_id); g_object_unref(window); g_object_unref(display); gst_deinit(); return 0; }
/********************************************** * main */ int main(int argc, char *argv[]) { AVB_TRACE_ENTRY(AVB_TRACE_HOST); int iniIdx = 0; char *programName; char *optIfnameGlobal = NULL; programName = strrchr(argv[0], '/'); programName = programName ? programName + 1 : argv[0]; if (argc < 2) { openavbTlHostUsage(programName); exit(-1); } tl_handle_t *tlHandleList = NULL; int i1; // Process command line bool optDone = FALSE; while (!optDone) { int opt = getopt(argc, argv, "hI:"); if (opt != EOF) { switch (opt) { case 'I': optIfnameGlobal = strdup(optarg); break; case 'h': default: openavbTlHostUsage(programName); exit(-1); } } else { optDone = TRUE; } } osalAVBInitialize(optIfnameGlobal); iniIdx = optind; U32 tlCount = argc - iniIdx; if (!openavbTLInitialize(tlCount)) { AVB_LOG_ERROR("Unable to initialize talker listener library"); osalAVBFinalize(); exit(-1); } // Setup signal handler // We catch SIGINT and shutdown cleanly bool err; struct sigaction sa; sa.sa_handler = openavbTLSigHandler; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; err = sigaction(SIGINT, &sa, NULL); if (err) { AVB_LOG_ERROR("Failed to setup SIGINT handler"); osalAVBFinalize(); exit(-1); } err = sigaction(SIGUSR1, &sa, NULL); if (err) { AVB_LOG_ERROR("Failed to setup SIGUSR1 handler"); osalAVBFinalize(); exit(-1); } registerStaticMapModule(openavbMapPipeInitialize); registerStaticMapModule(openavbMapAVTPAudioInitialize); registerStaticMapModule(openavbMapCtrlInitialize); registerStaticMapModule(openavbMapH264Initialize); registerStaticMapModule(openavbMapMjpegInitialize); registerStaticMapModule(openavbMapMpeg2tsInitialize); registerStaticMapModule(openavbMapNullInitialize); registerStaticMapModule(openavbMapUncmpAudioInitialize); registerStaticIntfModule(openavbIntfEchoInitialize); registerStaticIntfModule(openavbIntfCtrlInitialize); registerStaticIntfModule(openavbIntfLoggerInitialize); registerStaticIntfModule(openavbIntfNullInitialize); registerStaticIntfModule(openavbIntfToneGenInitialize); registerStaticIntfModule(openavbIntfViewerInitialize); registerStaticIntfModule(openavbIntfAlsaInitialize); registerStaticIntfModule(openavbIntfMjpegGstInitialize); registerStaticIntfModule(openavbIntfMpeg2tsFileInitialize); registerStaticIntfModule(openavbIntfMpeg2tsGstInitialize); registerStaticIntfModule(openavbIntfWavFileInitialize); registerStaticIntfModule(openavbIntfH264RtpGstInitialize); tlHandleList = calloc(1, sizeof(tl_handle_t) * tlCount); // Open all streams for (i1 = 0; i1 < tlCount; i1++) { tlHandleList[i1] = openavbTLOpen(); } // Parse ini and configure all streams for (i1 = 0; i1 < tlCount; i1++) { openavb_tl_cfg_t cfg; openavb_tl_cfg_name_value_t NVCfg; char iniFile[1024]; snprintf(iniFile, sizeof(iniFile), "%s", argv[i1 + iniIdx]); if (optIfnameGlobal && !strcasestr(iniFile, ",ifname=")) { snprintf(iniFile + strlen(iniFile), sizeof(iniFile), ",ifname=%s", optIfnameGlobal); } openavbTLInitCfg(&cfg); memset(&NVCfg, 0, sizeof(NVCfg)); if (!openavbTLReadIniFileOsal(tlHandleList[i1], iniFile, &cfg, &NVCfg)) { AVB_LOGF_ERROR("Error reading ini file: %s\n", argv[i1 + 1]); osalAVBFinalize(); exit(-1); } if (!openavbTLConfigure(tlHandleList[i1], &cfg, &NVCfg)) { AVB_LOGF_ERROR("Error configuring: %s\n", argv[i1 + 1]); osalAVBFinalize(); exit(-1); } int i2; for (i2 = 0; i2 < NVCfg.nLibCfgItems; i2++) { free(NVCfg.libCfgNames[i2]); free(NVCfg.libCfgValues[i2]); } } #ifdef AVB_FEATURE_GSTREAMER // If we're supporting the interface modules which use GStreamer, // initialize GStreamer here to avoid errors. gst_init(0, NULL); #endif for (i1 = 0; i1 < tlCount; i1++) { openavbTLRun(tlHandleList[i1]); } while (bRunning) { sleep(1); } for (i1 = 0; i1 < tlCount; i1++) { openavbTLStop(tlHandleList[i1]); } for (i1 = 0; i1 < tlCount; i1++) { openavbTLClose(tlHandleList[i1]); } openavbTLCleanup(); #ifdef AVB_FEATURE_GSTREAMER // If we're supporting the interface modules which use GStreamer, // De-initialize GStreamer to clean up resources. gst_deinit(); #endif osalAVBFinalize(); AVB_TRACE_EXIT(AVB_TRACE_HOST); exit(0); }
int main (int argc, char **argv) { DBusGConnection *session_bus; GError *error = NULL; RBShell *rb_shell; gboolean activated; gboolean autostarted; char *accel_map_file = NULL; char *desktop_file_path; GOptionContext *context; static const GOptionEntry options [] = { { "debug", 'd', 0, G_OPTION_ARG_NONE, &debug, N_("Enable debug output"), NULL }, { "debug-match", 'D', 0, G_OPTION_ARG_STRING, &debug_match, N_("Enable debug output matching a specified string"), NULL }, { "no-update", 0, 0, G_OPTION_ARG_NONE, &no_update, N_("Do not update the library with file changes"), NULL }, { "no-registration", 'n', 0, G_OPTION_ARG_NONE, &no_registration, N_("Do not register the shell"), NULL }, { "dry-run", 0, 0, G_OPTION_ARG_NONE, &dry_run, N_("Don't save any data permanently (implies --no-registration)"), NULL }, { "disable-plugins", 0, 0, G_OPTION_ARG_NONE, &disable_plugins, N_("Disable loading of plugins"), NULL }, { "rhythmdb-file", 0, 0, G_OPTION_ARG_STRING, &rhythmdb_file, N_("Path for database file to use"), NULL }, { "playlists-file", 0, 0, G_OPTION_ARG_STRING, &playlists_file, N_("Path for playlists file to use"), NULL }, { "quit", 'q', 0, G_OPTION_ARG_NONE, &quit, N_("Quit Rhythmbox"), NULL }, { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &remaining_args, NULL, N_("[URI...]") }, { NULL } }; g_thread_init (NULL); rb_profile_start ("starting rhythmbox"); autostarted = (g_getenv ("DESKTOP_AUTOSTART_ID") != NULL); #ifdef USE_UNINSTALLED_DIRS desktop_file_path = g_build_filename (SHARE_UNINSTALLED_BUILDDIR, "rhythmbox.desktop", NULL); g_setenv ("GSETTINGS_SCHEMA_DIR", SHARE_UNINSTALLED_BUILDDIR, TRUE); #else desktop_file_path = g_build_filename (DATADIR, "applications", "rhythmbox.desktop", NULL); #endif egg_set_desktop_file (desktop_file_path); g_free (desktop_file_path); context = g_option_context_new (NULL); g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); rb_profile_start ("initializing gstreamer"); g_option_context_add_group (context, gst_init_get_option_group ()); rb_profile_end ("initializing gstreamer"); g_option_context_add_group (context, egg_sm_client_get_option_group ()); g_option_context_add_group (context, gtk_get_option_group (TRUE)); setlocale (LC_ALL, NULL); rb_profile_start ("parsing command line options"); if (g_option_context_parse (context, &argc, &argv, &error) == FALSE) { g_print (_("%s\nRun '%s --help' to see a full list of available command line options.\n"), error->message, argv[0]); g_error_free (error); g_option_context_free (context); exit (1); } g_option_context_free (context); rb_profile_end ("parsing command line options"); g_random_set_seed (time (0)); #ifdef ENABLE_NLS /* initialize i18n */ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); /* ask for utf-8 message text from GStreamer too, * since it doesn't do that itself. */ bind_textdomain_codeset ("gstreamer-0.10", "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif if (!debug && debug_match) rb_debug_init_match (debug_match); else rb_debug_init (debug); rb_debug ("initializing Rhythmbox %s", VERSION); #if defined(USE_UNINSTALLED_DIRS) g_irepository_prepend_search_path (SHARE_UNINSTALLED_BUILDDIR "/../bindings/gi"); #endif /* TODO: kill this function */ rb_threads_init (); gdk_threads_enter (); activated = FALSE; rb_debug ("going to create DBus object"); dbus_g_thread_init (); session_bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error); if (session_bus == NULL) { g_warning ("couldn't connect to session bus: %s", (error) ? error->message : "(null)"); g_clear_error (&error); } else if (!no_registration) { guint request_name_reply; int flags; #ifndef DBUS_NAME_FLAG_DO_NOT_QUEUE flags = DBUS_NAME_FLAG_PROHIBIT_REPLACEMENT; #else flags = DBUS_NAME_FLAG_DO_NOT_QUEUE; #endif DBusGProxy *bus_proxy; bus_proxy = dbus_g_proxy_new_for_name (session_bus, "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus"); if (!dbus_g_proxy_call (bus_proxy, "RequestName", &error, G_TYPE_STRING, "org.gnome.Rhythmbox", G_TYPE_UINT, flags, G_TYPE_INVALID, G_TYPE_UINT, &request_name_reply, G_TYPE_INVALID)) { g_warning ("Failed to invoke RequestName: %s", error->message); } g_object_unref (bus_proxy); if (request_name_reply == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER || request_name_reply == DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER) activated = FALSE; else if (request_name_reply == DBUS_REQUEST_NAME_REPLY_EXISTS || request_name_reply == DBUS_REQUEST_NAME_REPLY_IN_QUEUE) activated = TRUE; else { g_warning ("Got unhandled reply %u from RequestName", request_name_reply); activated = FALSE; } } if (!activated) { if (quit) { rb_debug ("was asked to quit, but no instance was running"); gdk_notify_startup_complete (); exit (0); } #ifdef WITH_RHYTHMDB_GDA gda_init (PACKAGE, VERSION, argc, argv); #endif rb_refstring_system_init (); #ifdef USE_UNINSTALLED_DIRS rb_file_helpers_init (TRUE); #else rb_file_helpers_init (FALSE); #endif /* XXX not sure what to do with this. should we move it to * the config dir, or leave it where it is? */ accel_map_file = g_build_filename (g_get_home_dir (), ".gnome2", "accels", "rhythmbox", NULL); gtk_accel_map_load (accel_map_file); rb_debug ("Going to create a new shell"); rb_stock_icons_init (); g_setenv ("PULSE_PROP_media.role", "music", TRUE); rb_shell = rb_shell_new (no_registration, no_update, dry_run, autostarted, disable_plugins, rhythmdb_file, playlists_file); g_object_weak_ref (G_OBJECT (rb_shell), main_shell_weak_ref_cb, NULL); if (!no_registration && session_bus != NULL) { dbus_g_object_type_install_info (RB_TYPE_SHELL, &dbus_glib_rb_shell_object_info); dbus_g_connection_register_g_object (session_bus, "/org/gnome/Rhythmbox/Shell", G_OBJECT (rb_shell)); g_signal_connect (G_OBJECT (rb_shell), "database-load-complete", G_CALLBACK (database_load_complete), NULL); } } else if (!no_registration && session_bus != NULL) { DBusGProxy *shell_proxy; guint32 current_time; current_time = gdk_x11_display_get_user_time (gdk_display_get_default ()); shell_proxy = dbus_g_proxy_new_for_name_owner (session_bus, "org.gnome.Rhythmbox", "/org/gnome/Rhythmbox/Shell", "org.gnome.Rhythmbox.Shell", &error); if (!shell_proxy) { g_warning ("Couldn't create proxy for Rhythmbox shell: %s", error->message); } else { if (quit) { dbus_g_proxy_call_no_reply (shell_proxy, "quit", G_TYPE_INVALID); } else { load_uri_args ((const char **) remaining_args, (GFunc) dbus_load_uri, shell_proxy); dbus_g_proxy_call_no_reply (shell_proxy, "present", G_TYPE_UINT, current_time, G_TYPE_INVALID); } g_object_unref (G_OBJECT (shell_proxy)); } } if (activated) { gdk_notify_startup_complete (); } else { rb_profile_start ("mainloop"); #ifdef ENABLE_PYTHON if (rb_python_init_successful ()) { pyg_begin_allow_threads; gtk_main (); pyg_end_allow_threads; } else { gtk_main (); } #else gtk_main (); #endif rb_profile_end ("mainloop"); rb_debug ("out of toplevel loop"); rb_file_helpers_shutdown (); rb_stock_icons_shutdown (); rb_refstring_system_shutdown (); } gst_deinit (); rb_debug ("THE END"); rb_profile_end ("starting rhythmbox"); if (accel_map_file != NULL) { gtk_accel_map_save (accel_map_file); } gdk_threads_leave (); exit (0); }
GStreamerCore::~GStreamerCore() { _StopLoop(); gst_deinit(); }
/** main function */ int main (int argc, char *argv[]) { gchar *address = "0.0.0.0"; gchar *service = "8080"; char *docrootphys = NULL; gchar *cgiroot = NULL; char *cgirootphys = NULL; gchar *sysadmin = "server.json"; gchar *pidfile = NULL; gchar *device = NULL; GstHTTPServer *server; GstHTTPMediaMapping *mapping; GstHTTPMedia *media; GError *err = NULL; GOptionContext *ctx; gchar *configfile = NULL; gchar *input_dev = NULL; int i; GOptionEntry options[] = { {"config", 'f', 0, G_OPTION_ARG_STRING, &configfile, "config file", "file"}, {"address", 'a', 0, G_OPTION_ARG_STRING, &address, "address to listen on", "addr"}, {"service", 's', 0, G_OPTION_ARG_STRING, &service, "service to listen on", "service"}, {"docroot", 'd', 0, G_OPTION_ARG_STRING, &docroot, "root directory for www", "path"}, {"cgiroot", 'c', 0, G_OPTION_ARG_STRING, &cgiroot, "root directory for cgi-bin", "path"}, {"sysadmin", 0, 0, G_OPTION_ARG_STRING, &sysadmin, "path to sysadmin", "path"}, {"pidfile", 'p', 0, G_OPTION_ARG_STRING, &pidfile, "file to store pid", "filename"}, {"device", 0, 0, G_OPTION_ARG_STRING, &device, "video device", "filename"}, {"inputdev", 0, 0, G_OPTION_ARG_STRING, &input_dev, "device file for input", "filename"}, {NULL} }; printf("gst-mjpeg-streamer v%s\n", VERSION); /* must init the threading system before using any other glib function */ if (!g_thread_supported()) g_thread_init(NULL); GST_DEBUG_CATEGORY_INIT (gst_http_debug, "gst_http", 0, "gst_http"); ctx = g_option_context_new ("gst-httpd"); g_option_context_add_main_entries(ctx, options, NULL); g_option_context_add_group(ctx, gst_init_get_option_group()); if (!g_option_context_parse(ctx, &argc, &argv, &err)) { g_print ("Error initializing: %s\n", GST_STR_NULL(err->message)); exit (1); } /* install signal handler */ signal(SIGINT, sighandler); signal(SIGSEGV, sighandler); signal(SIGPIPE, SIG_IGN); /* init gstreamer and create mainloop */ gst_init (&argc, &argv); loop = g_main_loop_new (NULL, FALSE); /* create a server instance */ server = gst_http_server_new (); mapping = gst_http_server_get_media_mapping (server); gst_http_server_set_address (server, address); gst_http_server_set_service (server, service); /* if standalone video device - dynamically create configuration */ if (device) { v4l2_config_device(device, mapping, input_dev); } /* parse configfile */ if (configfile) { parse_config(server, configfile, input_dev); } /* parse commandline arguments */ i = 1; while ( (argc - i) >= 2) { media = gst_http_media_new_pipeline ("", argv[i+1], input_dev); gst_http_media_mapping_add (mapping, argv[i], media); i+=2; } if (pidfile) { FILE *fp = fopen(pidfile, "w+"); if (fp) { fprintf(fp, "%d", getpid()); fclose(fp); } else { perror ("open failed"); } } /* add custom URL handlers */ #ifdef V4L2_CTLS media = gst_http_media_new_handler ("Video Controls", v4l2_config, server); gst_http_media_mapping_add (mapping, "v4l2cfg.json", media); #endif if (sysadmin) { media = gst_http_media_new_handler ("Server Status", server_status, server); gst_http_media_mapping_add (mapping, sysadmin, media); } #ifdef CGI_PATH if (cgiroot) { cgirootphys = realpath(cgiroot, NULL); if (cgirootphys) { media = gst_http_media_new_handler ("CGI Handler", cgi_handoff, cgirootphys); gst_http_media_mapping_add (mapping, CGI_PATH "/*", media); } else { g_print ("Error: cgiroot '%s' not found\n", cgiroot); } } #endif #ifdef LOCAL_PAGES /* default to a page handler that serves from docroot */ if (docroot) { docrootphys = realpath(docroot, NULL); if (docrootphys) { media = gst_http_media_new_handler ("Page Handler", serve_page, docrootphys); gst_http_media_mapping_add (mapping, "*", media); } else { g_print ("Error: docroot '%s' not found\n", docroot); } } #endif // #ifdef LOCAL_PAGES /* make sure we have a valid configuration */ if (gst_http_media_mapping_num_mappings(mapping) == 0) { g_print ("Error: no streams defined\n"); g_print ("%s\n", g_option_context_get_help(ctx, 0, NULL)); return -1; } g_object_unref(mapping); g_option_context_free(ctx); /* attach the server to the default maincontext */ if (!gst_http_server_attach (server, NULL)) { fprintf(stderr, "Failed to attach server\n"); exit(1); } #ifdef SYS_STAT g_timeout_add(1000, sysstat_timer, NULL); #endif /* start serving */ g_print("%d: Listening on %s:%s\n", getpid(), address, service); g_main_loop_run (loop); GST_DEBUG("cleaning up..."); gst_http_server_detach (server); g_object_unref (server); if (docrootphys) free(docrootphys); g_main_loop_unref(loop); gst_deinit(); return 0; }
~GStreamerService () { gst_deinit (); }
int main (int argc, char *argv[]) { gst_init (&argc, &argv); GstElementFactory *factory = gst_element_factory_find("ffmpegcolorspace"); const GList *list = gst_element_factory_get_static_pad_templates(factory); while (NULL != list) { GstStaticPadTemplate *templ = (GstStaticPadTemplate *)list->data; // name g_print("+++ template name %s\n", templ->name_template); // direction g_print ("direction: "); switch (templ->direction) { case GST_PAD_UNKNOWN: g_print ("unknown\n"); break; case GST_PAD_SRC: g_print ("src\n"); break; case GST_PAD_SINK: g_print ("sink\n"); break; default: g_print ("this is a bug\n"); break; } // presence g_print ("presence: "); switch (templ->presence) { case GST_PAD_ALWAYS: g_print ("always\n"); break; case GST_PAD_SOMETIMES: g_print ("sometimes\n"); break; case GST_PAD_REQUEST: g_print ("request\n"); break; default: g_print ("this is a bug\n"); break; } // caps GstCaps *caps = gst_static_caps_get(&templ->static_caps); // copying for removing fields in struture GstCaps *copy = gst_caps_copy(caps); gst_caps_unref(caps); guint size = gst_caps_get_size(copy); guint i = 0; g_print("size %u\n", size); for (; i < size; i++) { GstStructure *structure = gst_caps_get_structure(copy, i); gst_structure_remove_fields(structure, "format", "width", "height", "framerate", NULL); GstCaps *copy_nth = gst_caps_copy_nth(copy, i); gchar *caps_str = gst_caps_to_string(copy_nth); g_print(" caps num %u is %s\n", i, caps_str); g_free(caps_str); gst_caps_unref(copy_nth); } gst_caps_unref(copy); list = g_list_next(list); } gst_object_unref(factory); gst_deinit(); // for memory testing return 0; }
int main(int argc, char *argv[]) { GstVaapiDisplay *display, *display2; guint width, height, par_n, par_d; gst_init(&argc, &argv); #if USE_DRM g_print("#\n"); g_print("# Create display with gst_vaapi_display_drm_new()\n"); g_print("#\n"); { display = gst_vaapi_display_drm_new(NULL); if (!display) g_error("could not create Gst/VA display"); dump_info(display); gst_vaapi_display_unref(display); } g_print("\n"); g_print("#\n"); g_print("# Create display with gst_vaapi_display_drm_new_with_device()\n"); g_print("#\n"); { int drm_device; drm_device = open(DRM_DEVICE_PATH, O_RDWR|O_CLOEXEC); if (drm_device < 0) g_error("could not open DRM device"); display = gst_vaapi_display_drm_new_with_device(drm_device); if (!display) g_error("could not create Gst/VA display"); dump_info(display); gst_vaapi_display_unref(display); close(drm_device); } g_print("\n"); g_print("#\n"); g_print("# Create display with gst_vaapi_display_new_with_display() [vaGetDisplayDRM()]\n"); g_print("#\n"); { int drm_device; VADisplay va_display; drm_device = open(DRM_DEVICE_PATH, O_RDWR|O_CLOEXEC); if (drm_device < 0) g_error("could not open DRM device"); va_display = vaGetDisplayDRM(drm_device); if (!va_display) g_error("could not create VA display"); display = gst_vaapi_display_new_with_display(va_display); if (!display) g_error("could not create Gst/VA display"); dump_info(display); gst_vaapi_display_unref(display); close(drm_device); } g_print("\n"); #endif #if USE_X11 g_print("#\n"); g_print("# Create display with gst_vaapi_display_x11_new()\n"); g_print("#\n"); { display = gst_vaapi_display_x11_new(NULL); if (!display) g_error("could not create Gst/VA display"); if (CHECK_DISPLAY_CACHE) { display2 = gst_vaapi_display_x11_new(NULL); /* Check for the same X11 display */ g_assert(gst_vaapi_display_x11_get_display( GST_VAAPI_DISPLAY_X11(display)) == gst_vaapi_display_x11_get_display( GST_VAAPI_DISPLAY_X11(display2))); /* Check for the same VA display */ g_assert(gst_vaapi_display_get_display(display) == gst_vaapi_display_get_display(display2)); gst_vaapi_display_unref(display2); #if USE_GLX display2 = gst_vaapi_display_glx_new(NULL); /* Check for the different X11 display */ /* XXX: it is also desired to cache underlying X11 displays */ g_assert(gst_vaapi_display_x11_get_display( GST_VAAPI_DISPLAY_X11(display)) != gst_vaapi_display_x11_get_display( GST_VAAPI_DISPLAY_X11(display2))); /* Check for different VA display */ g_assert(gst_vaapi_display_get_display(display) != gst_vaapi_display_get_display(display2)); gst_vaapi_display_unref(display2); #endif } gst_vaapi_display_get_size(display, &width, &height); g_print("Display size: %ux%u\n", width, height); gst_vaapi_display_get_pixel_aspect_ratio(display, &par_n, &par_d); g_print("Pixel aspect ratio: %u/%u\n", par_n, par_d); dump_info(display); gst_vaapi_display_unref(display); } g_print("\n"); g_print("#\n"); g_print("# Create display with gst_vaapi_display_x11_new_with_display()\n"); g_print("#\n"); { Display *x11_display; x11_display = XOpenDisplay(NULL); if (!x11_display) g_error("could not create X11 display"); display = gst_vaapi_display_x11_new_with_display(x11_display); if (!display) g_error("could not create Gst/VA display"); if (CHECK_DISPLAY_CACHE) { display2 = gst_vaapi_display_x11_new_with_display(x11_display); /* Check for the same VA display */ g_assert(gst_vaapi_display_get_display(display) == gst_vaapi_display_get_display(display2)); gst_vaapi_display_unref(display2); } dump_info(display); gst_vaapi_display_unref(display); XCloseDisplay(x11_display); } g_print("\n"); g_print("#\n"); g_print("# Create display with gst_vaapi_display_new_with_display() [vaGetDisplay()]\n"); g_print("#\n"); { Display *x11_display; VADisplay va_display; x11_display = XOpenDisplay(NULL); if (!x11_display) g_error("could not create X11 display"); va_display = vaGetDisplay(x11_display); if (!va_display) g_error("could not create VA display"); display = gst_vaapi_display_new_with_display(va_display); if (!display) g_error("could not create Gst/VA display"); dump_info(display); gst_vaapi_display_unref(display); XCloseDisplay(x11_display); } g_print("\n"); #endif #if USE_GLX g_print("#\n"); g_print("# Create display with gst_vaapi_display_glx_new()\n"); g_print("#\n"); { display = gst_vaapi_display_glx_new(NULL); if (!display) g_error("could not create Gst/VA display"); if (CHECK_DISPLAY_CACHE) { display2 = gst_vaapi_display_glx_new(NULL); /* Check for the same X11 display */ g_assert(gst_vaapi_display_x11_get_display( GST_VAAPI_DISPLAY_X11(display)) == gst_vaapi_display_x11_get_display( GST_VAAPI_DISPLAY_X11(display2))); /* Check for the same VA display */ g_assert(gst_vaapi_display_get_display(display) == gst_vaapi_display_get_display(display2)); gst_vaapi_display_unref(display2); display2 = gst_vaapi_display_x11_new(NULL); /* Check for the same X11 display */ g_assert(gst_vaapi_display_x11_get_display( GST_VAAPI_DISPLAY_X11(display)) == gst_vaapi_display_x11_get_display( GST_VAAPI_DISPLAY_X11(display2))); /* Check for the same VA display */ g_assert(gst_vaapi_display_get_display(display) == gst_vaapi_display_get_display(display2)); gst_vaapi_display_unref(display2); } gst_vaapi_display_get_size(display, &width, &height); g_print("Display size: %ux%u\n", width, height); gst_vaapi_display_get_pixel_aspect_ratio(display, &par_n, &par_d); g_print("Pixel aspect ratio: %u/%u\n", par_n, par_d); dump_info(display); gst_vaapi_display_unref(display); } g_print("\n"); g_print("#\n"); g_print("# Create display with gst_vaapi_display_glx_new_with_display()\n"); g_print("#\n"); { Display *x11_display; x11_display = XOpenDisplay(NULL); if (!x11_display) g_error("could not create X11 display"); display = gst_vaapi_display_glx_new_with_display(x11_display); if (!display) g_error("could not create Gst/VA display"); dump_info(display); gst_vaapi_display_unref(display); XCloseDisplay(x11_display); } g_print("\n"); #ifdef HAVE_VA_VA_GLX_H g_print("#\n"); g_print("# Create display with gst_vaapi_display_new_with_display() [vaGetDisplayGLX()]\n"); g_print("#\n"); { Display *x11_display; VADisplay va_display; x11_display = XOpenDisplay(NULL); if (!x11_display) g_error("could not create X11 display"); va_display = vaGetDisplayGLX(x11_display); if (!va_display) g_error("could not create VA display"); display = gst_vaapi_display_new_with_display(va_display); if (!display) g_error("could not create Gst/VA display"); dump_info(display); gst_vaapi_display_unref(display); XCloseDisplay(x11_display); } g_print("\n"); #endif #endif #if USE_WAYLAND g_print("#\n"); g_print("# Create display with gst_vaapi_display_wayland_new()\n"); g_print("#\n"); { display = gst_vaapi_display_wayland_new(NULL); if (!display) g_error("could not create Gst/VA display"); gst_vaapi_display_get_size(display, &width, &height); g_print("Display size: %ux%u\n", width, height); gst_vaapi_display_get_pixel_aspect_ratio(display, &par_n, &par_d); g_print("Pixel aspect ratio: %u/%u\n", par_n, par_d); dump_info(display); gst_vaapi_display_unref(display); } g_print("\n"); #endif gst_deinit(); return 0; }
static void gstreamer_exit_library() { gst_deinit(); return; }
static void gt_player_backend_gstreamer_cairo_class_finalize(GtPlayerBackendGstreamerCairoClass* klass) { if (gst_is_initialized()) gst_deinit(); }
void shmdata_any_reader_clean_before_exiting () { gst_deinit (); }
int main (int argc, char **argv) { ServiceData svc = {0,}; GError *error = NULL; const char *address = NULL; char *guid; #ifdef ENABLE_NLS /* initialize i18n */ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif g_type_init (); gst_init (NULL, NULL); g_set_prgname ("rhythmbox-metadata"); if (argv[1] != NULL && strcmp(argv[1], "--debug") == 0) { argv++; rb_debug_init (TRUE); } else if (argv[1] != NULL && strcmp (argv[1], "--debug-match") == 0) { rb_debug_init_match (argv[2]); argv += 2; } else { rb_debug_init (FALSE); } /* bug report modes */ if (argv[1] != NULL && strcmp(argv[1], "--load") == 0) { return test_load (argv[2]); } if (argv[1] != NULL && strcmp(argv[1], "--saveable-types") == 0) { return test_saveable_types (); } if (argv[1] != NULL && strcmp (argv[1], "--external") == 0) { argv++; svc.external = TRUE; } if (argv[1] == NULL) { address = "unix:tmpdir=/tmp"; } else { address = argv[1]; } rb_debug ("initializing metadata service; pid = %d; address = %s", getpid (), address); svc.metadata = rb_metadata_new (); svc.loop = g_main_loop_new (NULL, TRUE); /* create the server */ guid = g_dbus_generate_guid (); svc.server = g_dbus_server_new_sync (address, G_DBUS_SERVER_FLAGS_NONE, guid, NULL, NULL, &error); g_free (guid); if (error != NULL) { g_warning ("D-Bus server init failed: %s", error->message); return -1; } /* set up interface info */ svc.node_info = g_dbus_node_info_new_for_xml (rb_metadata_iface_xml, &error); if (error != NULL) { g_warning ("D-Bus server init failed: %s", error->message); return -1; } g_signal_connect (svc.server, "new-connection", G_CALLBACK (new_connection_cb), &svc); g_dbus_server_start (svc.server); /* write the server address back to the parent process */ { const char *addr; addr = g_dbus_server_get_client_address (svc.server); rb_debug ("D-BUS server listening on address %s", addr); printf ("%s\n", addr); fflush (stdout); } /* run main loop until we get bored */ if (!svc.external) g_timeout_add_seconds (ATTENTION_SPAN / 2, (GSourceFunc) electromagnetic_shotgun, &svc); g_main_loop_run (svc.loop); if (svc.connection) { g_dbus_connection_close_sync (svc.connection, NULL, NULL); g_object_unref (svc.connection); } g_object_unref (svc.metadata); g_main_loop_unref (svc.loop); g_dbus_server_stop (svc.server); g_object_unref (svc.server); gst_deinit (); return 0; }
static Eina_Bool _gst_init(const char *filename) { GstPad *pad; GstCaps *caps; GstStructure *structure; gchar *descr; gchar *uri; GError *error = NULL; GstFormat format; GstStateChangeReturn ret; if (!filename || !*filename) return EINA_FALSE; if (!gst_init_check(NULL, NULL, &error)) return EINA_FALSE; if ((*filename == '/') || (*filename == '~')) { uri = g_filename_to_uri(filename, NULL, NULL); if (!uri) { D("could not create new uri from %s", filename); goto unref_pipeline; } } else uri = strdup(filename); D("Setting file %s\n", uri); descr = g_strdup_printf("uridecodebin uri=%s ! ffmpegcolorspace ! " " appsink name=sink caps=\"" CAPS "\"", uri); pipeline = gst_parse_launch(descr, &error); free(uri); if (error != NULL) { D("could not construct pipeline: %s\n", error->message); g_error_free (error); goto gst_shutdown; } sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink"); ret = gst_element_set_state (pipeline, GST_STATE_PAUSED); switch (ret) { case GST_STATE_CHANGE_FAILURE: D("failed to play the file\n"); goto unref_pipeline; case GST_STATE_CHANGE_NO_PREROLL: D("live sources not supported yet\n"); goto unref_pipeline; default: break; } ret = gst_element_get_state((pipeline), NULL, NULL, GST_CLOCK_TIME_NONE); if (ret == GST_STATE_CHANGE_FAILURE) { D("could not complete pause\n"); goto unref_pipeline; } format = GST_FORMAT_TIME; gst_element_query_duration (pipeline, &format, &duration); if (duration == -1) { D("could not retrieve the duration, set it to 1s\n"); duration = 1 * GST_SECOND; } pad = gst_element_get_static_pad(sink, "sink"); if (!pad) { D("could not retrieve the sink pad\n"); goto unref_pipeline; } caps = gst_pad_get_negotiated_caps(pad); if (!caps) goto unref_pad; structure = gst_caps_get_structure(caps, 0); if (!gst_structure_get_int(structure, "width", &width)) goto unref_caps; if (!gst_structure_get_int(structure, "height", &height)) goto unref_caps; gst_caps_unref(caps); gst_object_unref(pad); return EINA_TRUE; unref_caps: gst_caps_unref(caps); unref_pad: gst_object_unref(pad); unref_pipeline: gst_element_set_state (pipeline, GST_STATE_NULL); gst_object_unref(pipeline); gst_shutdown: gst_deinit(); return EINA_FALSE; }
static int mod_gst_close(void) { gst_deinit(); ausrc = mem_deref(ausrc); return 0; }
int main (int argc, char *argv[]) { GtkWidget *window, *window_control; GtkWidget *button_state_null, *button_state_ready; GtkWidget *button_state_paused, *button_state_playing; GtkWidget *grid, *area; GstElement *pipeline; GstElement *videosrc, *videosink; GstStateChangeReturn ret; GstCaps *caps; GstBus *bus; gst_init (&argc, &argv); gtk_init (&argc, &argv); pipeline = gst_pipeline_new ("pipeline"); //window that contains an area where the video is drawn window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (window), 640, 480); gtk_window_move (GTK_WINDOW (window), 300, 10); gtk_window_set_title (GTK_WINDOW (window), "gtkgstwidget"); //window to control the states window_control = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_resizable (GTK_WINDOW (window_control), FALSE); gtk_window_move (GTK_WINDOW (window_control), 10, 10); grid = gtk_grid_new (); gtk_container_add (GTK_CONTAINER (window_control), grid); //control state null button_state_null = gtk_button_new_with_label ("GST_STATE_NULL"); g_signal_connect (G_OBJECT (button_state_null), "clicked", G_CALLBACK (button_state_null_cb), pipeline); gtk_grid_attach (GTK_GRID (grid), button_state_null, 0, 1, 1, 1); gtk_widget_show (button_state_null); //control state ready button_state_ready = gtk_button_new_with_label ("GST_STATE_READY"); g_signal_connect (G_OBJECT (button_state_ready), "clicked", G_CALLBACK (button_state_ready_cb), pipeline); gtk_grid_attach (GTK_GRID (grid), button_state_ready, 0, 2, 1, 1); gtk_widget_show (button_state_ready); //control state paused button_state_paused = gtk_button_new_with_label ("GST_STATE_PAUSED"); g_signal_connect (G_OBJECT (button_state_paused), "clicked", G_CALLBACK (button_state_paused_cb), pipeline); gtk_grid_attach (GTK_GRID (grid), button_state_paused, 0, 3, 1, 1); gtk_widget_show (button_state_paused); //control state playing button_state_playing = gtk_button_new_with_label ("GST_STATE_PLAYING"); g_signal_connect (G_OBJECT (button_state_playing), "clicked", G_CALLBACK (button_state_playing_cb), pipeline); gtk_grid_attach (GTK_GRID (grid), button_state_playing, 0, 4, 1, 1); gtk_widget_show (button_state_playing); gtk_widget_show (grid); gtk_widget_show (window_control); g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (destroy_cb), pipeline); //configure the pipeline videosrc = gst_element_factory_make ("videotestsrc", "videotestsrc"); videosink = gst_element_factory_make ("gtksink", "gtksink"); g_object_get (videosink, "widget", &area, NULL); gtk_container_add (GTK_CONTAINER (window), area); g_object_unref (area); gtk_widget_realize (area); caps = gst_caps_new_simple ("video/x-raw", "width", G_TYPE_INT, 640, "height", G_TYPE_INT, 480, "format", G_TYPE_STRING, "BGRA", NULL); gst_bin_add_many (GST_BIN (pipeline), videosrc, videosink, NULL); if (!gst_element_link_filtered (videosrc, videosink, caps)) { gst_caps_unref (caps); g_warning ("Failed to link videosrc to glfiltercube!\n"); return -1; } gst_caps_unref (caps); //set window id on this event bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); g_signal_connect (bus, "message::error", G_CALLBACK (end_stream_cb), pipeline); g_signal_connect (bus, "message::warning", G_CALLBACK (end_stream_cb), pipeline); g_signal_connect (bus, "message::eos", G_CALLBACK (end_stream_cb), pipeline); gst_object_unref (bus); //start ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); if (ret == GST_STATE_CHANGE_FAILURE) { g_print ("Failed to start up pipeline!\n"); return -1; } gtk_widget_show_all (window); gtk_main (); gst_deinit (); return 0; }
void video_output_exit (void) { g_free (g_output_name); gst_deinit (); }
int main (int argc, char **argv) { GstPlay *play; GPtrArray *playlist; gboolean verbose = FALSE; gboolean print_version = FALSE; gboolean interactive = TRUE; gboolean gapless = FALSE; gboolean shuffle = FALSE; gdouble volume = -1; gchar **filenames = NULL; gchar *audio_sink = NULL; gchar *video_sink = NULL; gchar **uris; gchar *flags = NULL; guint num, i; GError *err = NULL; GOptionContext *ctx; gchar *playlist_file = NULL; GOptionEntry options[] = { {"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, N_("Output status information and property notifications"), NULL}, {"flags", 0, 0, G_OPTION_ARG_STRING, &flags, N_("Control playback behaviour setting playbin 'flags' property"), NULL}, {"version", 0, 0, G_OPTION_ARG_NONE, &print_version, N_("Print version information and exit"), NULL}, {"videosink", 0, 0, G_OPTION_ARG_STRING, &video_sink, N_("Video sink to use (default is autovideosink)"), NULL}, {"audiosink", 0, 0, G_OPTION_ARG_STRING, &audio_sink, N_("Audio sink to use (default is autoaudiosink)"), NULL}, {"gapless", 0, 0, G_OPTION_ARG_NONE, &gapless, N_("Enable gapless playback"), NULL}, {"shuffle", 0, 0, G_OPTION_ARG_NONE, &shuffle, N_("Shuffle playlist"), NULL}, {"no-interactive", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &interactive, N_("Disable interactive control via the keyboard"), NULL}, {"volume", 0, 0, G_OPTION_ARG_DOUBLE, &volume, N_("Volume"), NULL}, {"playlist", 0, 0, G_OPTION_ARG_FILENAME, &playlist_file, N_("Playlist file containing input media files"), NULL}, {"quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet, N_("Do not print any output (apart from errors)"), NULL}, {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL}, {NULL} }; setlocale (LC_ALL, ""); #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif g_set_prgname ("gst-play-" GST_API_VERSION); ctx = g_option_context_new ("FILE1|URI1 [FILE2|URI2] [FILE3|URI3] ..."); g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE); g_option_context_add_group (ctx, gst_init_get_option_group ()); if (!g_option_context_parse (ctx, &argc, &argv, &err)) { g_print ("Error initializing: %s\n", GST_STR_NULL (err->message)); g_option_context_free (ctx); g_clear_error (&err); return 1; } g_option_context_free (ctx); GST_DEBUG_CATEGORY_INIT (play_debug, "play", 0, "gst-play"); if (print_version) { gchar *version_str; version_str = gst_version_string (); g_print ("%s version %s\n", g_get_prgname (), PACKAGE_VERSION); g_print ("%s\n", version_str); g_print ("%s\n", GST_PACKAGE_ORIGIN); g_free (version_str); g_free (audio_sink); g_free (video_sink); g_free (playlist_file); return 0; } playlist = g_ptr_array_new (); if (playlist_file != NULL) { gchar *playlist_contents = NULL; gchar **lines = NULL; if (g_file_get_contents (playlist_file, &playlist_contents, NULL, &err)) { lines = g_strsplit (playlist_contents, "\n", 0); num = g_strv_length (lines); for (i = 0; i < num; i++) { if (lines[i][0] != '\0') { GST_LOG ("Playlist[%d]: %s", i + 1, lines[i]); add_to_playlist (playlist, lines[i]); } } g_strfreev (lines); g_free (playlist_contents); } else { g_printerr ("Could not read playlist: %s\n", err->message); g_clear_error (&err); } g_free (playlist_file); playlist_file = NULL; } if (playlist->len == 0 && (filenames == NULL || *filenames == NULL)) { g_printerr (_("Usage: %s FILE1|URI1 [FILE2|URI2] [FILE3|URI3] ..."), "gst-play-" GST_API_VERSION); g_printerr ("\n\n"), g_printerr ("%s\n\n", _("You must provide at least one filename or URI to play.")); /* No input provided. Free array */ g_ptr_array_free (playlist, TRUE); g_free (audio_sink); g_free (video_sink); return 1; } /* fill playlist */ if (filenames != NULL && *filenames != NULL) { num = g_strv_length (filenames); for (i = 0; i < num; ++i) { GST_LOG ("command line argument: %s", filenames[i]); add_to_playlist (playlist, filenames[i]); } g_strfreev (filenames); } num = playlist->len; g_ptr_array_add (playlist, NULL); uris = (gchar **) g_ptr_array_free (playlist, FALSE); if (shuffle) shuffle_uris (uris, num); /* prepare */ play = play_new (uris, audio_sink, video_sink, gapless, volume, verbose, flags); if (play == NULL) { g_printerr ("Failed to create 'playbin' element. Check your GStreamer installation.\n"); return EXIT_FAILURE; } if (interactive) { if (gst_play_kb_set_key_handler (keyboard_cb, play)) { g_print (_("Press 'k' to see a list of keyboard shortcuts.\n")); atexit (restore_terminal); } else { g_print ("Interactive keyboard handling in terminal not available.\n"); } } /* play */ do_play (play); /* clean up */ play_free (play); g_free (audio_sink); g_free (video_sink); g_print ("\n"); gst_deinit (); return 0; }
int main (int argc, char **argv) { ServiceData svc = {0,}; DBusError dbus_error = {0,}; const char *address = NULL; #ifdef ENABLE_NLS /* initialize i18n */ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif g_type_init (); gst_init (NULL, NULL); g_set_prgname ("rhythmbox-metadata"); if (argv[1] != NULL && strcmp(argv[1], "--debug") == 0) { argv++; rb_debug_init (TRUE); } else if (argv[1] != NULL && strcmp (argv[1], "--debug-match") == 0) { rb_debug_init_match (argv[2]); argv += 2; } else { rb_debug_init (FALSE); } /* bug report modes */ if (argv[1] != NULL && strcmp(argv[1], "--load") == 0) { return test_load (argv[2]); } if (argv[1] != NULL && strcmp(argv[1], "--saveable-types") == 0) { return test_saveable_types (); } if (argv[1] != NULL && strcmp (argv[1], "--external") == 0) { argv++; svc.external = TRUE; } if (argv[1] == NULL) { address = "unix:tmpdir=/tmp"; } else { address = argv[1]; } rb_debug ("initializing metadata service; pid = %d; address = %s", getpid (), address); svc.metadata = rb_metadata_new (); /* set up D-BUS server */ svc.server = dbus_server_listen (address, &dbus_error); if (!svc.server) { rb_debug ("D-BUS server init failed: %s", dbus_error.message); return -1; } dbus_server_set_new_connection_function (svc.server, _new_connection, (gpointer) &svc, NULL); /* write the server address back to the parent process */ { char *addr; addr = dbus_server_get_address (svc.server); rb_debug ("D-BUS server listening on address %s", addr); printf ("%s\n", addr); fflush (stdout); free (addr); } /* run main loop until we get bored */ svc.loop = g_main_loop_new (NULL, TRUE); dbus_server_setup_with_g_main (svc.server, g_main_loop_get_context (svc.loop)); if (!svc.external) g_timeout_add_seconds (ATTENTION_SPAN / 2, (GSourceFunc) electromagnetic_shotgun, &svc); g_main_loop_run (svc.loop); if (svc.connection) { dbus_connection_close (svc.connection); dbus_connection_unref (svc.connection); } g_object_unref (svc.metadata); g_main_loop_unref (svc.loop); dbus_server_disconnect (svc.server); dbus_server_unref (svc.server); gst_deinit (); return 0; }