static SwfdecAudioDecoder *
swfdec_audio_decoder_gst_create (guint type, SwfdecAudioFormat format)
{
  SwfdecAudioDecoderGst *player;
  GstCaps *srccaps, *sinkcaps;
  const char *resample;

  srccaps = swfdec_audio_decoder_get_caps (type, format);
  if (srccaps == NULL)
    return NULL;

  player = g_object_new (SWFDEC_TYPE_AUDIO_DECODER_GST, NULL);

  /* create decoder */
  sinkcaps = gst_caps_from_string ("audio/x-raw-int, endianness=byte_order, signed=(boolean)true, width=16, depth=16, rate=44100, channels=2");
  g_assert (sinkcaps);
  resample = swfdec_audio_decoder_get_resampler ();
  if (resample == NULL)
    goto error;
  if (!swfdec_gst_decoder_init (&player->dec, srccaps, sinkcaps, 
	"audioconvert", resample, NULL))
    goto error;

  gst_caps_unref (srccaps);
  gst_caps_unref (sinkcaps);
  return SWFDEC_AUDIO_DECODER (player);

error:
  g_object_unref (player);
  gst_caps_unref (srccaps);
  gst_caps_unref (sinkcaps);
  return NULL;
}
Beispiel #2
0
void
VideoDecoderGst::setup(GstCaps* srccaps)
{
    if (!srccaps) {
        throw MediaException(_("VideoDecoderGst: internal error "
                    "(caps creation failed)"));      
    }

    bool success = GstUtil::check_missing_plugins(srccaps);
    if (!success) {
        GstStructure* sct = gst_caps_get_structure(srccaps, 0);
        std::string type(gst_structure_get_name(sct));
        std::string msg = (boost::format(_("Couldn't find a plugin for "
                    "video type %s!")) % type).str();

        if (type == "video/x-flash-video" || type == "video/x-h264") {
            msg += _(" Please make sure you have gstreamer-ffmpeg installed.");
        }

        gst_caps_unref(srccaps);

        throw MediaException(msg);
    }

    GstCaps* sinkcaps = gst_caps_new_simple("video/x-raw-rgb", "bpp",
            G_TYPE_INT, 24,
            "depth", G_TYPE_INT, 24,
            NULL);

    if (!sinkcaps) {
        throw MediaException(_("VideoDecoderGst: internal error "
                    "(caps creation failed)"));      
    }

    bool rv = swfdec_gst_decoder_init (&_decoder, srccaps, sinkcaps,
            "ffmpegcolorspace", NULL);
    if (!rv) {
        throw MediaException(_("VideoDecoderGst: initialisation failed."));      
    }

    gst_caps_unref (srccaps);
    gst_caps_unref (sinkcaps);
}
Beispiel #3
0
void AudioDecoderGst::setup(GstCaps* srccaps)
{
    if (!srccaps) {
        throw MediaException(_("AudioDecoderGst: internal error (caps creation failed)"));      
    }

    bool success = GstUtil::check_missing_plugins(srccaps);
    if (!success) {
        GstStructure* sct = gst_caps_get_structure(srccaps, 0);
        std::string type(gst_structure_get_name(sct));
        std::string msg = (boost::format(_("Couldn't find a plugin for "
                    "audio type %s!")) % type).str();

        gst_caps_unref(srccaps);

        throw MediaException(msg);
    }


    GstCaps* sinkcaps = gst_caps_from_string ("audio/x-raw-int, "
            "endianness=byte_order, signed=(boolean)true, width=16, "
            "depth=16, rate=44100, channels=2");
    if (!sinkcaps) {
        throw MediaException(_("AudioDecoderGst: internal error "
                    "(caps creation failed)"));      
    }

    std::string resampler = findResampler();

    success = swfdec_gst_decoder_init (&_decoder, srccaps, sinkcaps, "audioconvert", resampler.c_str(), NULL);
    if (!success) {
        GstStructure* sct = gst_caps_get_structure(srccaps, 0);
        std::string type(gst_structure_get_name(sct));
        std::string msg = (boost::format(
            _("AudioDecoderGst: initialisation failed for audio type %s!"))
            % type).str();
        throw MediaException(msg);
    }

    gst_caps_unref (srccaps);
    gst_caps_unref (sinkcaps);
}
static SwfdecVideoDecoder *
swfdec_video_decoder_gst_create (guint codec)
{
  SwfdecVideoDecoderGst *player;
  GstCaps *srccaps, *sinkcaps;

  srccaps = swfdec_video_decoder_get_caps (codec);
  if (srccaps == NULL)
    return NULL;
  sinkcaps = swfdec_video_decoder_get_sink_caps (codec);

  player = g_object_new (SWFDEC_TYPE_VIDEO_DECODER_GST, NULL);

  if (!swfdec_gst_decoder_init (&player->dec, srccaps, sinkcaps, NULL)) {
    g_object_unref (player);
    gst_caps_unref (srccaps);
    gst_caps_unref (sinkcaps);
    return NULL;
  }

  gst_caps_unref (srccaps);
  gst_caps_unref (sinkcaps);
  return &player->decoder;
}