Changeset 238606 in webkit


Ignore:
Timestamp:
Nov 28, 2018 4:41:51 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

[WebRTC][GStreamer] Use a GUniquePtr to hold the GstAudioConverter in our OutgoingAudioSource
https://bugs.webkit.org/show_bug.cgi?id=192027

Patch by Thibault Saunier <tsaunier@igalia.com> on 2018-11-28
Reviewed by Xabier Rodriguez-Calvar.

Cleaning up a bit the code.

It is a minor refactoring, no new test required.

  • platform/graphics/gstreamer/GUniquePtrGStreamer.h:
  • platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.cpp:

(WebCore::RealtimeOutgoingAudioSourceLibWebRTC::~RealtimeOutgoingAudioSourceLibWebRTC):
(WebCore::RealtimeOutgoingAudioSourceLibWebRTC::audioSamplesAvailable):
(WebCore::RealtimeOutgoingAudioSourceLibWebRTC::pullAudioData):

  • platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.h:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r238605 r238606  
     12018-11-28  Thibault Saunier  <tsaunier@igalia.com>
     2
     3        [WebRTC][GStreamer] Use a GUniquePtr to hold the GstAudioConverter in our OutgoingAudioSource
     4        https://bugs.webkit.org/show_bug.cgi?id=192027
     5
     6        Reviewed by Xabier Rodriguez-Calvar.
     7
     8        Cleaning up a bit the code.
     9
     10        It is a minor refactoring, no new test required.
     11
     12        * platform/graphics/gstreamer/GUniquePtrGStreamer.h:
     13        * platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.cpp:
     14        (WebCore::RealtimeOutgoingAudioSourceLibWebRTC::~RealtimeOutgoingAudioSourceLibWebRTC):
     15        (WebCore::RealtimeOutgoingAudioSourceLibWebRTC::audioSamplesAvailable):
     16        (WebCore::RealtimeOutgoingAudioSourceLibWebRTC::pullAudioData):
     17        * platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.h:
     18
    1192018-11-28  Thibault Saunier  <tsaunier@igalia.com>
    220
  • trunk/Source/WebCore/platform/graphics/gstreamer/GUniquePtrGStreamer.h

    r238557 r238606  
    2222#if USE(GSTREAMER)
    2323
     24#include <gst/audio/audio.h>
    2425#include <gst/base/gstbytereader.h>
    2526#include <gst/base/gstflowcombiner.h>
     
    3940WTF_DEFINE_GPTR_DELETER(GstByteReader, gst_byte_reader_free)
    4041WTF_DEFINE_GPTR_DELETER(GstVideoConverter, gst_video_converter_free)
     42WTF_DEFINE_GPTR_DELETER(GstAudioConverter, gst_audio_converter_free)
    4143
    4244}
  • trunk/Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.cpp

    r238224 r238606  
    4040{
    4141    unobserveSource();
    42     if (m_sampleConverter)
    43         g_clear_pointer(&m_sampleConverter, gst_audio_converter_free);
     42    m_sampleConverter = nullptr;
    4443}
    4544
     
    7574    if (m_sampleConverter && !gst_audio_info_is_equal(m_inputStreamDescription->getInfo(), desc.getInfo())) {
    7675        GST_ERROR_OBJECT(this, "FIXME - Audio format renegotiation is not possible yet!");
    77         g_clear_pointer(&m_sampleConverter, gst_audio_converter_free);
     76        m_sampleConverter = nullptr;
    7877    }
    7978
     
    8180        m_inputStreamDescription = std::unique_ptr<GStreamerAudioStreamDescription>(new GStreamerAudioStreamDescription(desc.getInfo()));
    8281        m_outputStreamDescription = libwebrtcAudioFormat(LibWebRTCAudioFormat::sampleRate, streamDescription.numberOfChannels());
    83 
    84         m_sampleConverter = gst_audio_converter_new(GST_AUDIO_CONVERTER_FLAG_IN_WRITABLE,
     82        m_sampleConverter.reset(gst_audio_converter_new(GST_AUDIO_CONVERTER_FLAG_IN_WRITABLE,
    8583            m_inputStreamDescription->getInfo(),
    8684            m_outputStreamDescription->getInfo(),
    87             nullptr);
     85            nullptr));
    8886    }
    8987
     
    108106
    109107    LockHolder locker(m_adapterMutex);
    110     size_t inChunkSampleCount = gst_audio_converter_get_in_frames(m_sampleConverter, outChunkSampleCount);
     108    size_t inChunkSampleCount = gst_audio_converter_get_in_frames(m_sampleConverter.get(), outChunkSampleCount);
    111109    size_t inBufferSize = inChunkSampleCount * m_inputStreamDescription->getInfo()->bpf;
    112110
     
    129127        gpointer in[1] = { inMap.data() };
    130128        gpointer out[1] = { outMap.data() };
    131         if (!gst_audio_converter_samples(m_sampleConverter, static_cast<GstAudioConverterFlags>(0), in, inChunkSampleCount, out, outChunkSampleCount)) {
     129        if (!gst_audio_converter_samples(m_sampleConverter.get(), static_cast<GstAudioConverterFlags>(0), in, inChunkSampleCount, out, outChunkSampleCount)) {
    132130            GST_ERROR("Could not convert samples.");
    133131
  • trunk/Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.h

    r234138 r238606  
    4949    void pullAudioData() final;
    5050
    51     GstAudioConverter* m_sampleConverter;
     51    GUniquePtr<GstAudioConverter> m_sampleConverter;
    5252    std::unique_ptr<GStreamerAudioStreamDescription> m_inputStreamDescription;
    5353    std::unique_ptr<GStreamerAudioStreamDescription> m_outputStreamDescription;
Note: See TracChangeset for help on using the changeset viewer.