Modified: trunk/Source/WebCore/ChangeLog (238605 => 238606)
--- trunk/Source/WebCore/ChangeLog 2018-11-28 12:40:08 UTC (rev 238605)
+++ trunk/Source/WebCore/ChangeLog 2018-11-28 12:41:51 UTC (rev 238606)
@@ -1,5 +1,23 @@
2018-11-28 Thibault Saunier <[email protected]>
+ [WebRTC][GStreamer] Use a GUniquePtr to hold the GstAudioConverter in our OutgoingAudioSource
+ https://bugs.webkit.org/show_bug.cgi?id=192027
+
+ 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:
+
+2018-11-28 Thibault Saunier <[email protected]>
+
[GStreamer][WebRTC] Do not run device monitor for device type we do not handle
https://bugs.webkit.org/show_bug.cgi?id=191904
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GUniquePtrGStreamer.h (238605 => 238606)
--- trunk/Source/WebCore/platform/graphics/gstreamer/GUniquePtrGStreamer.h 2018-11-28 12:40:08 UTC (rev 238605)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GUniquePtrGStreamer.h 2018-11-28 12:41:51 UTC (rev 238606)
@@ -21,6 +21,7 @@
#define GUniquePtrGStreamer_h
#if USE(GSTREAMER)
+#include <gst/audio/audio.h>
#include <gst/base/gstbytereader.h>
#include <gst/base/gstflowcombiner.h>
#include <gst/gstsegment.h>
@@ -38,6 +39,7 @@
WTF_DEFINE_GPTR_DELETER(GstFlowCombiner, gst_flow_combiner_free)
WTF_DEFINE_GPTR_DELETER(GstByteReader, gst_byte_reader_free)
WTF_DEFINE_GPTR_DELETER(GstVideoConverter, gst_video_converter_free)
+WTF_DEFINE_GPTR_DELETER(GstAudioConverter, gst_audio_converter_free)
}
Modified: trunk/Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.cpp (238605 => 238606)
--- trunk/Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.cpp 2018-11-28 12:40:08 UTC (rev 238605)
+++ trunk/Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.cpp 2018-11-28 12:41:51 UTC (rev 238606)
@@ -39,8 +39,7 @@
RealtimeOutgoingAudioSourceLibWebRTC::~RealtimeOutgoingAudioSourceLibWebRTC()
{
unobserveSource();
- if (m_sampleConverter)
- g_clear_pointer(&m_sampleConverter, gst_audio_converter_free);
+ m_sampleConverter = nullptr;
}
Ref<RealtimeOutgoingAudioSource> RealtimeOutgoingAudioSource::create(Ref<MediaStreamTrackPrivate>&& audioSource)
@@ -74,17 +73,16 @@
if (m_sampleConverter && !gst_audio_info_is_equal(m_inputStreamDescription->getInfo(), desc.getInfo())) {
GST_ERROR_OBJECT(this, "FIXME - Audio format renegotiation is not possible yet!");
- g_clear_pointer(&m_sampleConverter, gst_audio_converter_free);
+ m_sampleConverter = nullptr;
}
if (!m_sampleConverter) {
m_inputStreamDescription = std::unique_ptr<GStreamerAudioStreamDescription>(new GStreamerAudioStreamDescription(desc.getInfo()));
m_outputStreamDescription = libwebrtcAudioFormat(LibWebRTCAudioFormat::sampleRate, streamDescription.numberOfChannels());
-
- m_sampleConverter = gst_audio_converter_new(GST_AUDIO_CONVERTER_FLAG_IN_WRITABLE,
+ m_sampleConverter.reset(gst_audio_converter_new(GST_AUDIO_CONVERTER_FLAG_IN_WRITABLE,
m_inputStreamDescription->getInfo(),
m_outputStreamDescription->getInfo(),
- nullptr);
+ nullptr));
}
LockHolder locker(m_adapterMutex);
@@ -107,7 +105,7 @@
size_t outBufferSize = outChunkSampleCount * m_outputStreamDescription->getInfo()->bpf;
LockHolder locker(m_adapterMutex);
- size_t inChunkSampleCount = gst_audio_converter_get_in_frames(m_sampleConverter, outChunkSampleCount);
+ size_t inChunkSampleCount = gst_audio_converter_get_in_frames(m_sampleConverter.get(), outChunkSampleCount);
size_t inBufferSize = inChunkSampleCount * m_inputStreamDescription->getInfo()->bpf;
auto available = gst_adapter_available(m_adapter.get());
@@ -128,7 +126,7 @@
gpointer in[1] = { inMap.data() };
gpointer out[1] = { outMap.data() };
- if (!gst_audio_converter_samples(m_sampleConverter, static_cast<GstAudioConverterFlags>(0), in, inChunkSampleCount, out, outChunkSampleCount)) {
+ if (!gst_audio_converter_samples(m_sampleConverter.get(), static_cast<GstAudioConverterFlags>(0), in, inChunkSampleCount, out, outChunkSampleCount)) {
GST_ERROR("Could not convert samples.");
return;
Modified: trunk/Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.h (238605 => 238606)
--- trunk/Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.h 2018-11-28 12:40:08 UTC (rev 238605)
+++ trunk/Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.h 2018-11-28 12:41:51 UTC (rev 238606)
@@ -48,7 +48,7 @@
void pullAudioData() final;
- GstAudioConverter* m_sampleConverter;
+ GUniquePtr<GstAudioConverter> m_sampleConverter;
std::unique_ptr<GStreamerAudioStreamDescription> m_inputStreamDescription;
std::unique_ptr<GStreamerAudioStreamDescription> m_outputStreamDescription;