mozilla-gstreamer-1.patch
changeset 637 73640b76d6c3
parent 627 cc7671532e60
child 641 8d4c4f06e0e4
equal deleted inserted replaced
636:0dd4ede5105c 637:73640b76d6c3
     1 # HG changeset patch
     1 # HG changeset patch
     2 # Parent 0559be6b60075e1a708ca90e874f922ff200c462
     2 # Parent bbef353e571ee80b20c52274c7660b49d01985ba
     3 # User Mike Gorse <mgorse@suse.com>
     3 # User Mike Gorse <mgorse@suse.com>
     4 
     4 
     5 Bug 806917 - support GStreamer 1.0
     5 Bug 806917 - support GStreamer 1.0
     6 
     6 
     7 diff --git a/configure.in b/configure.in
     7 diff --git a/configure.in b/configure.in
     8 --- a/configure.in
     8 --- a/configure.in
     9 +++ b/configure.in
     9 +++ b/configure.in
    10 @@ -5758,28 +5758,36 @@ fi
    10 @@ -5706,26 +5706,34 @@ fi
    11  
    11  
    12  AC_SUBST(MOZ_PULSEAUDIO)
    12  AC_SUBST(MOZ_PULSEAUDIO)
    13  AC_SUBST(MOZ_PULSEAUDIO_CFLAGS)
    13  AC_SUBST(MOZ_PULSEAUDIO_CFLAGS)
    14  AC_SUBST(MOZ_PULSEAUDIO_LIBS)
    14  AC_SUBST(MOZ_PULSEAUDIO_LIBS)
    15  
    15  
    33  
    33  
    34  if test "$MOZ_GSTREAMER"; then
    34  if test "$MOZ_GSTREAMER"; then
    35 -    # API version, eg 0.10, 1.0 etc
    35 -    # API version, eg 0.10, 1.0 etc
    36 -    GST_API_VERSION=0.10
    36 -    GST_API_VERSION=0.10
    37      # core/base release number
    37      # core/base release number
    38      # depend on >= 0.10.33 as that's when the playbin2 source-setup signal was
    38 -    GST_VERSION=0.10.25
    39      # introduced
       
    40 -    GST_VERSION=0.10.33
       
    41 +    if test "$GST_API_VERSION" = "1.0"; then
    39 +    if test "$GST_API_VERSION" = "1.0"; then
    42 +      GST_VERSION=1.0
    40 +      GST_VERSION=1.0
    43 +    else
    41 +    else
    44 +      GST_VERSION=0.10.33
    42 +      GST_VERSION=0.10.25
    45 +    fi
    43 +    fi
    46      PKG_CHECK_MODULES(GSTREAMER,
    44      PKG_CHECK_MODULES(GSTREAMER,
    47                        gstreamer-$GST_API_VERSION >= $GST_VERSION
    45                        gstreamer-$GST_API_VERSION >= $GST_VERSION
    48                        gstreamer-app-$GST_API_VERSION
    46                        gstreamer-app-$GST_API_VERSION
    49                        gstreamer-plugins-base-$GST_API_VERSION)
    47                        gstreamer-plugins-base-$GST_API_VERSION)
   100  }
    98  }
   101  
    99  
   102  GStreamerReader::~GStreamerReader()
   100  GStreamerReader::~GStreamerReader()
   103  {
   101  {
   104    MOZ_COUNT_DTOR(GStreamerReader);
   102    MOZ_COUNT_DTOR(GStreamerReader);
   105 @@ -120,19 +124,26 @@ nsresult GStreamerReader::Init(MediaDeco
   103 @@ -122,19 +126,26 @@ nsresult GStreamerReader::Init(MediaDeco
   106    mVideoSink = gst_parse_bin_from_description("capsfilter name=filter ! "
   104    mVideoSink = gst_parse_bin_from_description("capsfilter name=filter ! "
   107        "appsink name=videosink sync=true max-buffers=1 "
   105        "appsink name=videosink sync=true max-buffers=1 "
   108        "caps=video/x-raw-yuv,format=(fourcc)I420"
   106        "caps=video/x-raw-yuv,format=(fourcc)I420"
   109        , TRUE, NULL);
   107        , TRUE, NULL);
   110    mVideoAppSink = GST_APP_SINK(gst_bin_get_by_name(GST_BIN(mVideoSink),
   108    mVideoAppSink = GST_APP_SINK(gst_bin_get_by_name(GST_BIN(mVideoSink),
   126  
   124  
   127    mAudioSink = gst_parse_bin_from_description("capsfilter name=filter ! "
   125    mAudioSink = gst_parse_bin_from_description("capsfilter name=filter ! "
   128  #ifdef MOZ_SAMPLE_TYPE_FLOAT32
   126  #ifdef MOZ_SAMPLE_TYPE_FLOAT32
   129          "appsink name=audiosink sync=true caps=audio/x-raw-float,"
   127          "appsink name=audiosink sync=true caps=audio/x-raw-float,"
   130  #ifdef IS_LITTLE_ENDIAN
   128  #ifdef IS_LITTLE_ENDIAN
   131          "channels={1,2},rate=44100,width=32,endianness=1234", TRUE, NULL);
   129          "channels={1,2},width=32,endianness=1234", TRUE, NULL);
   132  #else
   130  #else
   133 @@ -145,19 +156,25 @@ nsresult GStreamerReader::Init(MediaDeco
   131 @@ -147,19 +158,25 @@ nsresult GStreamerReader::Init(MediaDeco
   134  #else
   132  #else
   135          "channels={1,2},rate=48000,width=16,endianness=4321", TRUE, NULL);
   133          "channels={1,2},width=16,endianness=4321", TRUE, NULL);
   136  #endif
   134  #endif
   137  #endif
   135  #endif
   138    mAudioAppSink = GST_APP_SINK(gst_bin_get_by_name(GST_BIN(mAudioSink),
   136    mAudioAppSink = GST_APP_SINK(gst_bin_get_by_name(GST_BIN(mAudioSink),
   139          "audiosink"));
   137          "audiosink"));
   140    gst_app_sink_set_callbacks(mAudioAppSink, &mSinkCallbacks,
   138    gst_app_sink_set_callbacks(mAudioAppSink, &mSinkCallbacks,
   154    g_object_set(mPlayBin, "uri", "appsrc://",
   152    g_object_set(mPlayBin, "uri", "appsrc://",
   155        "video-sink", mVideoSink,
   153        "video-sink", mVideoSink,
   156        "audio-sink", mAudioSink,
   154        "audio-sink", mAudioSink,
   157        NULL);
   155        NULL);
   158  
   156  
   159    g_object_connect(mPlayBin, "signal::source-setup",
   157    g_signal_connect(G_OBJECT(mPlayBin), "notify::source",
   160 @@ -231,17 +248,17 @@ nsresult GStreamerReader::ReadMetadata(V
   158 @@ -236,17 +253,17 @@ nsresult GStreamerReader::ReadMetadata(V
   161        filter = gst_bin_get_by_name(GST_BIN(mAudioSink), "filter");
   159        filter = gst_bin_get_by_name(GST_BIN(mAudioSink), "filter");
   162      else if (!(current_flags & GST_PLAY_FLAG_VIDEO))
   160      else if (!(current_flags & GST_PLAY_FLAG_VIDEO))
   163        filter = gst_bin_get_by_name(GST_BIN(mVideoSink), "filter");
   161        filter = gst_bin_get_by_name(GST_BIN(mVideoSink), "filter");
   164  
   162  
   165      if (filter) {
   163      if (filter) {
   174      }
   172      }
   175  
   173  
   176      /* start the pipeline */
   174      /* start the pipeline */
   177      gst_element_set_state(mPlayBin, GST_STATE_PAUSED);
   175      gst_element_set_state(mPlayBin, GST_STATE_PAUSED);
   178  
   176  
   179 @@ -284,19 +301,24 @@ nsresult GStreamerReader::ReadMetadata(V
   177 @@ -289,19 +306,24 @@ nsresult GStreamerReader::ReadMetadata(V
   180        gst_element_set_state(mPlayBin, GST_STATE_NULL);
   178        gst_element_set_state(mPlayBin, GST_STATE_NULL);
   181        gst_message_unref(message);
   179        gst_message_unref(message);
   182        return NS_ERROR_FAILURE;
   180        return NS_ERROR_FAILURE;
   183      }
   181      }
   184    }
   182    }
   199      duration = GST_TIME_AS_USECONDS (duration);
   197      duration = GST_TIME_AS_USECONDS (duration);
   200      mDecoder->SetMediaDuration(duration);
   198      mDecoder->SetMediaDuration(duration);
   201    }
   199    }
   202  
   200  
   203    int n_video = 0, n_audio = 0;
   201    int n_video = 0, n_audio = 0;
   204 @@ -365,59 +387,87 @@ bool GStreamerReader::DecodeAudioData()
   202 @@ -370,59 +392,87 @@ bool GStreamerReader::DecodeAudioData()
   205  {
   203  {
   206    NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread.");
   204    NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread.");
   207  
   205  
   208    if (!WaitForDecodedData(&mAudioSinkBufferCount)) {
   206    if (!WaitForDecodedData(&mAudioSinkBufferCount)) {
   209      mAudioQueue.Finish();
   207      mAudioQueue.Finish();
   287  
   285  
   288      timestamp = GST_BUFFER_TIMESTAMP(buffer);
   286      timestamp = GST_BUFFER_TIMESTAMP(buffer);
   289      {
   287      {
   290        ReentrantMonitorAutoEnter mon(mGstThreadsMonitor);
   288        ReentrantMonitorAutoEnter mon(mGstThreadsMonitor);
   291        timestamp = gst_segment_to_stream_time(&mVideoSegment,
   289        timestamp = gst_segment_to_stream_time(&mVideoSegment,
   292 @@ -431,62 +481,90 @@ bool GStreamerReader::DecodeVideoFrame(b
   290 @@ -436,62 +486,90 @@ bool GStreamerReader::DecodeVideoFrame(b
   293      else if (fpsNum && fpsDen)
   291      else if (fpsNum && fpsDen)
   294        /* add 1-frame duration */
   292        /* add 1-frame duration */
   295        nextTimestamp += gst_util_uint64_scale(GST_USECOND, fpsNum, fpsDen);
   293        nextTimestamp += gst_util_uint64_scale(GST_USECOND, fpsNum, fpsDen);
   296  
   294  
   297      if (timestamp < aTimeThreshold) {
   295      if (timestamp < aTimeThreshold) {
   378  
   376  
   379  nsresult GStreamerReader::Seek(int64_t aTarget,
   377  nsresult GStreamerReader::Seek(int64_t aTarget,
   380                                   int64_t aStartTime,
   378                                   int64_t aStartTime,
   381                                   int64_t aEndTime,
   379                                   int64_t aEndTime,
   382                                   int64_t aCurrentTime)
   380                                   int64_t aCurrentTime)
   383 @@ -509,52 +587,62 @@ nsresult GStreamerReader::Seek(int64_t a
   381 @@ -514,52 +592,62 @@ nsresult GStreamerReader::Seek(int64_t a
   384  
   382  
   385  nsresult GStreamerReader::GetBuffered(nsTimeRanges* aBuffered,
   383  nsresult GStreamerReader::GetBuffered(nsTimeRanges* aBuffered,
   386                                          int64_t aStartTime)
   384                                          int64_t aStartTime)
   387  {
   385  {
   388    if (!mInfo.mHasVideo && !mInfo.mHasAudio) {
   386    if (!mInfo.mHasVideo && !mInfo.mHasAudio) {
   444      LOG(PR_LOG_DEBUG, ("adding range [%f, %f] for [%li %li] size %li",
   442      LOG(PR_LOG_DEBUG, ("adding range [%f, %f] for [%li %li] size %li",
   445            start, end, startOffset, endOffset, resourceLength));
   443            start, end, startOffset, endOffset, resourceLength));
   446      aBuffered->Add(start, end);
   444      aBuffered->Add(start, end);
   447    }
   445    }
   448  
   446  
   449 @@ -563,48 +651,64 @@ nsresult GStreamerReader::GetBuffered(ns
   447 @@ -568,48 +656,64 @@ nsresult GStreamerReader::GetBuffered(ns
   450  
   448  
   451  void GStreamerReader::ReadAndPushData(guint aLength)
   449  void GStreamerReader::ReadAndPushData(guint aLength)
   452  {
   450  {
   453    MediaResource* resource = mDecoder->GetResource();
   451    MediaResource* resource = mDecoder->GetResource();
   454    NS_ASSERTION(resource, "Decoder has no media resource");
   452    NS_ASSERTION(resource, "Decoder has no media resource");
   510        duration = GST_TIME_AS_USECONDS (duration);
   508        duration = GST_TIME_AS_USECONDS (duration);
   511      }
   509      }
   512    }
   510    }
   513  
   511  
   514    /*if (mDecoder->mDuration != -1 &&
   512    /*if (mDecoder->mDuration != -1 &&
   515 @@ -668,60 +772,95 @@ gboolean GStreamerReader::SeekData(GstAp
   513 @@ -673,60 +777,95 @@ gboolean GStreamerReader::SeekData(GstAp
   516    if (NS_SUCCEEDED(rv))
   514    if (NS_SUCCEEDED(rv))
   517      mByteOffset = mLastReportedByteOffset = aOffset;
   515      mByteOffset = mLastReportedByteOffset = aOffset;
   518    else
   516    else
   519      LOG(PR_LOG_ERROR, ("seek at %lu failed", aOffset));
   517      LOG(PR_LOG_ERROR, ("seek at %lu failed", aOffset));
   520  
   518  
   606                                                gpointer aUserData)
   604                                                gpointer aUserData)
   607  {
   605  {
   608    GStreamerReader *reader = (GStreamerReader *) aUserData;
   606    GStreamerReader *reader = (GStreamerReader *) aUserData;
   609  
   607  
   610    if (aSink == reader->mVideoAppSink)
   608    if (aSink == reader->mVideoAppSink)
   611 @@ -730,18 +869,22 @@ GstFlowReturn GStreamerReader::NewPrerol
   609 @@ -735,18 +874,22 @@ GstFlowReturn GStreamerReader::NewPrerol
   612      reader->AudioPreroll();
   610      reader->AudioPreroll();
   613    return GST_FLOW_OK;
   611    return GST_FLOW_OK;
   614  }
   612  }
   615  
   613  
   616  void GStreamerReader::AudioPreroll()
   614  void GStreamerReader::AudioPreroll()
   630    gst_structure_get_int(s, "channels", (gint *) &mInfo.mAudioChannels);
   628    gst_structure_get_int(s, "channels", (gint *) &mInfo.mAudioChannels);
   631    NS_ASSERTION(mInfo.mAudioRate != 0, ("audio rate is zero"));
   629    NS_ASSERTION(mInfo.mAudioRate != 0, ("audio rate is zero"));
   632    NS_ASSERTION(mInfo.mAudioChannels != 0, ("audio channels is zero"));
   630    NS_ASSERTION(mInfo.mAudioChannels != 0, ("audio channels is zero"));
   633    NS_ASSERTION(mInfo.mAudioChannels > 0 && mInfo.mAudioChannels <= MAX_CHANNELS,
   631    NS_ASSERTION(mInfo.mAudioChannels > 0 && mInfo.mAudioChannels <= MAX_CHANNELS,
   634        "invalid audio channels number");
   632        "invalid audio channels number");
   635 @@ -749,19 +892,29 @@ void GStreamerReader::AudioPreroll()
   633 @@ -754,19 +897,29 @@ void GStreamerReader::AudioPreroll()
   636    gst_caps_unref(caps);
   634    gst_caps_unref(caps);
   637    gst_object_unref(sinkpad);
   635    gst_object_unref(sinkpad);
   638  }
   636  }
   639  
   637  
   640  void GStreamerReader::VideoPreroll()
   638  void GStreamerReader::VideoPreroll()