/*! \author CIO-SLI \brief Gstreamer base player for omap (but also x86) play an uri using playbin Check that TI's plugin are here. If so use TI's sink with default/user options. */ /****************************************************************************** STD INCLUDES ******************************************************************************/ // for getopt #include #include #include // for strtol #include // strdup #include /****************************************************************************** SPECIFIC INCLUDES ******************************************************************************/ /****************************************************************************** TYPES ******************************************************************************/ //! TI Video codec enum typedef enum t_ti_plugins { TP_AUDDEC, TP_AUDDEC1, TP_VIDDEC, TP_VIDDEC2, TP_TISINK, TP_LAST } T_TI_PLUGINS ; //! stuff to parse struct options typedef struct t_options { gboolean bTestSink ; //!< Test the configured video sink gboolean bFrameAcc ; //!< Enable/Disable Frame Accel copy gchar * uri ; } T_OPTIONS ; /****************************************************************************** GLOBALS ******************************************************************************/ #define STR_TIAUDDEC "TIAuddec" #define STR_TIAUDDEC1 "TIAuddec1" #define STR_TIVIDEC "TIViddec" #define STR_TIVIDEC2 "TIViddec2" #define STR_TISINK "TIDmaiVideoSink" //! Liste des plugins const char * const g_szGstTIplugins[] = { STR_TIAUDDEC, STR_TIAUDDEC1, STR_TIVIDEC, STR_TIVIDEC2,STR_TISINK } ; //! options for the player and gstreamer static T_OPTIONS sOpts = {0} ; /****************************************************************************** PROTOYPES AND MACROS ******************************************************************************/ //! loop waiting for bus message static void event_loop (GstElement * pipe) ; //! Parse user options static gint opt_parse(gint argc, char * argv[], T_OPTIONS * popts) ; //! print usage static void print_usage(const gchar * name) ; //! free options ressources static void delete_opts(void) ; /****************************************************************************** FUNCTIONS ******************************************************************************/ //! Boucle principale int main (int argc, char *argv[]) { gint i; const gchar *nano_str ; guint major, minor, micro, nano; // factory to produce the gst TI element GstElementFactory *factory = NULL ; GstElement * VideoSink = NULL ; GstElement *playbin = NULL ; GstElement *videotestsrc = NULL ; // program // TODO parse user options // make sure we have a URI if (argc < 2) { print_usage(argv[0]) ; return -1; } // gst init if (opt_parse(argc, argv, &sOpts) !=0) { print_usage(argv[0]) ; return -1 ; } gst_init (&argc, &argv); // Now get version info gst_version (&major, &minor, µ, &nano); switch (nano) { case 1 : nano_str = "(CVS)"; break ; case 2 : nano_str = "(Prerelease)"; break ; default : nano_str = ""; break ; } printf ("This program is linked against GStreamer %d.%d.%d %s\n", major, minor, micro, nano_str); // Check that the TI's codec here and display info for(i=0 ; itype) { case GST_MESSAGE_EOS: gst_message_unref (message); return; case GST_MESSAGE_WARNING: case GST_MESSAGE_ERROR: gst_message_parse_error (message, &gerror, &debug); gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug); gst_message_unref (message); g_error_free (gerror); g_free (debug); return; default: gst_message_unref (message); break; } } } //! Parse user options static gint opt_parse(gint argc, char * argv[], T_OPTIONS * popts) { gint opt = 0; gint ret = 0 ; // for option string description see help function while ((opt=getopt(argc, argv, "vhta:z:")) != -1) { switch(opt) { case 'v': case 'h': ret = -1 ; break ; case 'w': popts->bTestSink = TRUE ; break ; case 'a': popts->bFrameAcc = (strtol(optarg, (char**)NULL, 10) == 0) ? FALSE : TRUE ; break ; case 'z': popts->uri = strdup(optarg) ; default : ret = 0 ; break; } } return 0 ; } //! print usage static void print_usage(const gchar * name) { g_print ("Usage: %s [options]\n", name); } //! free options ressources static void delete_opts(void) { free(sOpts.uri) ; }