int main() { pj_caching_pool cp; pj_caching_pool_init(&cp, NULL, 4000); CHECK(__FILE__, pj_init()); pjmedia_endpt *endpoint; pjmedia_endpt_create(&cp.factory, NULL, 1, &endpoint); //pjmedia_codec_register_audio_codecs(endpoint, NULL); pjmedia_codec_g711_init(endpoint); list_codecs(endpoint); pjmedia_codec_g711_deinit(); list_codecs(endpoint); return 0; }
int main(int argc, char *argv[]) { const char *codec_name, *repair_name; codec_id_t cid; repair_id_t rid; struct s_sndfile *sf_in = NULL, *sf_out = NULL; sndfile_fmt_t sff; double drop = 0.0; int ac, did_query = FALSE; int csra = TRUE; /* codec specific repair allowed */ long seed = 100; codec_init(); ac = 1; while(ac < argc && argv[ac][0] == '-') { if (strlen(argv[ac]) > 2) { /* should be -codecs or -repairs */ switch(argv[ac][1]) { case 'c': list_codecs(); break; case 'r': list_repairs(); break; default: usage(); } did_query = TRUE; } else { if (argc - ac < 1) { usage(); } switch(argv[ac][1]) { case 's': seed = atoi(argv[++ac]); break; case 'd': drop = strtod(argv[++ac], NULL); break; case 'c': cid = codec_get_by_name(argv[++ac]); codec_name = argv[ac]; break; case 'n': csra = FALSE; break; case 'r': resolve_repair(argv[++ac], &rid, &repair_name); break; case 'u': units_per_packet = atoi(argv[++ac]); break; default: usage(); } } ac++; } if (did_query == TRUE) { /* Not sensible to be running query and executing test */ exit(-1); } if (argc - ac != 2) { usage(); } if (snd_read_open(&sf_in, argv[ac], NULL) == FALSE) { fprintf(stderr, "Could not open %s\n", argv[ac]); exit(-1); } ac++; if (snd_get_format(sf_in, &sff) == FALSE) { fprintf(stderr, "Failed to get format of %s\n", argv[ac]); exit(-1); } if (snd_write_open(&sf_out, argv[ac], "au", &sff) == FALSE) { fprintf(stderr, "Could not open %s\n", argv[ac]); exit(-1); } if (file_and_codec_compatible(&sff, cid) == FALSE) { fprintf(stderr, "Codec and file type are not compatible\n"); exit(-1); } printf("# Parameters #\tseed: %ld #\tdrop: %.2f #\tcodec: %s #\tunits per packet: %d #\trepair: %s #\tcodec specific repair (when available): %d #\tsource file: %s #\tdestination file %s\n", seed, drop, codec_name, units_per_packet, repair_name, csra, argv[argc - 2], argv[argc - 1]); repair_set_codec_specific_allowed(csra); init_drop(seed, drop); test_repair(sf_out, cid, rid, sf_in); /* snd_read_close(&sf_in) not needed because files gets closed * at eof automatically. */ snd_write_close(&sf_out); codec_exit(); xmemdmp(); return 0; }
int main (int argc, char **argv) { GError *err = NULL; gchar *outputuri = NULL; gchar *format = NULL; gchar *aformat = NULL; gchar *vformat = NULL; gboolean allmissing = FALSE; gboolean listcodecs = FALSE; GOptionEntry options[] = { { "silent", 's', 0, G_OPTION_ARG_NONE, &silent, "Don't output the information structure", NULL }, { "outputuri", 'o', 0, G_OPTION_ARG_STRING, &outputuri, "URI to encode to", "URI (<protocol>://<location>)" }, { "format", 'f', 0, G_OPTION_ARG_STRING, &format, "Container format", "<GstCaps>" }, { "vformat", 'v', 0, G_OPTION_ARG_STRING, &vformat, "Video format", "<GstCaps>" }, { "aformat", 'a', 0, G_OPTION_ARG_STRING, &aformat, "Audio format", "<GstCaps>" }, { "allmissing", 'm', 0, G_OPTION_ARG_NONE, &allmissing, "encode to all matching format/codec that aren't specified", NULL }, { "list-codecs", 'l', 0, G_OPTION_ARG_NONE, &listcodecs, "list all available codecs and container formats", NULL }, {NULL} }; GOptionContext *ctx; GstEncodingProfile *prof; gchar *inputuri; ctx = g_option_context_new ("- encode URIs with GstProfile and encodebin"); 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", err->message); exit (1); } if (listcodecs) { list_codecs (); g_option_context_free (ctx); exit (0); } if (outputuri == NULL || argc != 2) { g_print ("%s", g_option_context_get_help (ctx, TRUE, NULL)); g_option_context_free (ctx); exit (-1); } g_option_context_free (ctx); /* Fixup outputuri to be a URI */ inputuri = ensure_uri (argv[1]); outputuri = ensure_uri (outputuri); if (allmissing) { GList *muxers; GstCaps *formats = NULL; GstCaps *vformats = NULL; GstCaps *aformats = NULL; guint f, v, a, flen, vlen, alen; if (!format) formats = gst_caps_list_container_formats (GST_RANK_NONE); else formats = gst_caps_from_string (format); if (!vformat) vformats = gst_caps_list_video_encoding_formats (GST_RANK_NONE); else vformats = gst_caps_from_string (vformat); if (!aformat) aformats = gst_caps_list_audio_encoding_formats (GST_RANK_NONE); else aformats = gst_caps_from_string (aformat); muxers = gst_element_factory_list_get_elements (GST_ELEMENT_FACTORY_TYPE_MUXER, GST_RANK_NONE); flen = gst_caps_get_size (formats); for (f = 0; f < flen; f++) { GstCaps *container = gst_caps_new_full (gst_caps_steal_structure (formats, 0), NULL); GstCaps *compatv = gst_caps_list_compatible_codecs (container, vformats, muxers); GstCaps *compata = gst_caps_list_compatible_codecs (container, aformats, muxers); vlen = gst_caps_get_size (compatv); alen = gst_caps_get_size (compata); for (v = 0; v < vlen; v++) { GstCaps *vcodec = gst_caps_new_full (gst_structure_copy (gst_caps_get_structure (compatv, v)), NULL); for (a = 0; a < alen; a++) { GstCaps *acodec = gst_caps_new_full (gst_structure_copy (gst_caps_get_structure (compata, a)), NULL); prof = create_profile ((GstCaps *) container, (GstCaps *) vcodec, (GstCaps *) acodec); if (G_UNLIKELY (prof == NULL)) { g_print ("Wrong arguments\n"); break; } outputuri = ensure_uri (generate_filename (container, vcodec, acodec)); transcode_file (inputuri, outputuri, prof); gst_encoding_profile_unref (prof); gst_caps_unref (acodec); } gst_caps_unref (vcodec); } gst_caps_unref (container); } } else { /* Create the profile */ prof = create_profile_from_string (format, vformat, aformat); if (G_UNLIKELY (prof == NULL)) { g_print ("Encoding arguments are not valid !\n"); return 1; } /* Transcode file */ transcode_file (inputuri, outputuri, prof); /* cleanup */ gst_encoding_profile_unref (prof); } return 0; }