Bug 1355048: P1. Have WebrtcMediaDataDecoder placeholder. r=jesup
authorJean-Yves Avenard <jyavenard@mozilla.com>
Mon, 10 Apr 2017 20:40:31 +0200
changeset 369163 5a280a5cc9a0f280e9a09fddb2e4b9b3984a0aaa
parent 369162 962c95ec8881654704e33cee4c7e2c75c45ff99c
child 369164 24bcb56d321318f97b55fdb9f0bccf721b838936
push id32192
push userkwierso@gmail.com
push dateTue, 18 Jul 2017 00:01:01 +0000
treeherdermozilla-central@efc0b1525edb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs1355048
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1355048: P1. Have WebrtcMediaDataDecoder placeholder. r=jesup The code currently does nothing. MozReview-Commit-ID: 6C0sLKIoJEV
dom/media/MediaPrefs.h
media/webrtc/signaling/signaling.gyp
media/webrtc/signaling/src/media-conduit/MediaDataDecoderCodec.cpp
media/webrtc/signaling/src/media-conduit/MediaDataDecoderCodec.h
media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
media/webrtc/signaling/src/media-conduit/WebrtcMediaDataDecoderCodec.cpp
media/webrtc/signaling/src/media-conduit/WebrtcMediaDataDecoderCodec.h
modules/libpref/init/all.js
--- a/dom/media/MediaPrefs.h
+++ b/dom/media/MediaPrefs.h
@@ -119,16 +119,18 @@ private:
 #ifdef MOZ_GONK_MEDIACODEC
   DECL_MEDIA_PREF("media.gonk.enabled",                       PDMGonkDecoderEnabled, bool, true);
 #endif
 #ifdef MOZ_WIDGET_ANDROID
   DECL_MEDIA_PREF("media.android-media-codec.enabled",        PDMAndroidMediaCodecEnabled, bool, false);
   DECL_MEDIA_PREF("media.android-media-codec.preferred",      PDMAndroidMediaCodecPreferred, bool, false);
   DECL_MEDIA_PREF("media.navigator.hardware.vp8_encode.acceleration_remote_enabled", RemoteMediaCodecVP8EncoderEnabled, bool, false);
 #endif
+  // WebRTC
+  DECL_MEDIA_PREF("media.navigator.mediadatadecoder_enabled", MediaDataDecoderEnabled, bool, false);
 #ifdef MOZ_FFMPEG
   DECL_MEDIA_PREF("media.ffmpeg.enabled",                     PDMFFmpegEnabled, bool, true);
   DECL_MEDIA_PREF("media.libavcodec.allow-obsolete",          LibavcodecAllowObsolete, bool, false);
 #endif
 #if defined(MOZ_FFMPEG) || defined(MOZ_FFVPX)
   DECL_MEDIA_PREF("media.ffmpeg.low-latency.enabled",         PDMFFmpegLowLatencyEnabled, bool, false);
 #endif
 #ifdef MOZ_FFVPX
--- a/media/webrtc/signaling/signaling.gyp
+++ b/media/webrtc/signaling/signaling.gyp
@@ -69,16 +69,17 @@
         './src/common/time_profiling',
         './src/media',
         './src/media-conduit',
         './src/mediapipeline',
         './src/peerconnection',
         './src/sdp/sipcc',
         '../../../dom/base',
         '../../../dom/media',
+        '../../../dom/media/platforms',
         '../../../media/mtransport',
         '../trunk',
         '../../libyuv/libyuv/include',
         '../../mtransport/third_party/nrappkit/src/util/libekr',
       ],
 
       #
       # DEPENDENCIES
@@ -274,17 +275,19 @@
           'defines' : [
             'NO_CHROMIUM_LOGGING',
             'USE_FAKE_PCOBSERVER',
           ],
         }],
         ['build_for_standalone==0', {
           'sources': [
             './src/media-conduit/GmpVideoCodec.cpp',
+            './src/media-conduit/MediaDataDecoderCodec.cpp',
             './src/media-conduit/WebrtcGmpVideoCodec.cpp',
+            './src/media-conduit/WebrtcMediaDataDecoderCodec.cpp',
           ],
         }],
         ['build_for_standalone!=0', {
           'include_dirs': [
             './test'
           ],
           'defines' : [
             'NO_CHROMIUM_LOGGING',
new file mode 100644
--- /dev/null
+++ b/media/webrtc/signaling/src/media-conduit/MediaDataDecoderCodec.cpp
@@ -0,0 +1,23 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "MediaDataDecoderCodec.h"
+
+namespace mozilla {
+
+/* static */ WebrtcVideoEncoder*
+MediaDataDecoderCodec::CreateEncoder(
+  webrtc::VideoCodecType aCodecType)
+{
+  return nullptr;
+}
+
+/* static */ WebrtcVideoDecoder*
+MediaDataDecoderCodec::CreateDecoder(
+  webrtc::VideoCodecType aCodecbType)
+{
+  return nullptr;
+}
+
+} // namespace mozilla
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/media/webrtc/signaling/src/media-conduit/MediaDataDecoderCodec.h
@@ -0,0 +1,33 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef MEDIA_DATA_DECODER_CODEC_H_
+#define MEDIA_DATA_DECODER_CODEC_H_
+
+#include "MediaConduitInterface.h"
+#include "webrtc/common_types.h"
+#include "webrtc/video_decoder.h"
+
+namespace mozilla {
+
+class MediaDataDecoderCodec
+{
+ public:
+  /**
+   * Create encoder object for codec type |aCodecType|. Return |nullptr| when
+   * failed.
+   */
+  static WebrtcVideoEncoder* CreateEncoder(
+    webrtc::VideoCodecType aCodecType);
+
+  /**
+   * Create decoder object for codec type |aCodecType|. Return |nullptr| when
+   * failed.
+   */
+  static WebrtcVideoDecoder* CreateDecoder(
+    webrtc::VideoCodecType aCodecType);
+};
+}
+
+#endif // MEDIA_DATA_DECODER_CODEC_H_
--- a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
+++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
@@ -47,16 +47,18 @@
 #include "OMXVideoCodec.h"
 #endif
 
 #ifdef MOZ_WEBRTC_MEDIACODEC
 #include "MediaCodecVideoCodec.h"
 #endif
 #include "WebrtcGmpVideoCodec.h"
 
+#include "MediaDataDecoderCodec.h"
+
 // for ntohs
 #ifdef _MSC_VER
 #include "Winsock2.h"
 #else
 #include <netinet/in.h>
 #endif
 
 #include <algorithm>
@@ -1432,16 +1434,22 @@ WebrtcVideoConduit::ConfigureRecvMediaCo
 webrtc::VideoDecoder*
 WebrtcVideoConduit::CreateDecoder(webrtc::VideoCodecType aType)
 {
   webrtc::VideoDecoder* decoder = nullptr;
 #ifdef MOZ_WEBRTC_MEDIACODEC
   bool enabled = false;
 #endif
 
+  // Attempt to create a decoder using MediaDataDecoder.
+  decoder = MediaDataDecoderCodec::CreateDecoder(aType);
+  if (decoder) {
+    return decoder;
+  }
+
   switch (aType) {
     case webrtc::VideoCodecType::kVideoCodecH264:
       // get an external decoder
 #ifdef MOZ_WEBRTC_OMX
       decoder = OMXVideoCodec::CreateDecoder(OMXVideoCodec::CodecType::CODEC_H264);
 #else
       decoder = GmpVideoCodec::CreateDecoder();
 #endif
new file mode 100644
--- /dev/null
+++ b/media/webrtc/signaling/src/media-conduit/WebrtcMediaDataDecoderCodec.cpp
@@ -0,0 +1,51 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "WebrtcMediaDataDecoderCodec.h"
+#include "PlatformDecoderModule.h"
+
+namespace mozilla {
+
+class MediaDataDecoder;
+
+WebrtcMediaDataDecoder::WebrtcMediaDataDecoder()
+{
+}
+
+WebrtcMediaDataDecoder::~WebrtcMediaDataDecoder()
+{
+}
+
+int32_t
+WebrtcMediaDataDecoder::InitDecode(const webrtc::VideoCodec* codecSettings,
+                                   int32_t numberOfCores)
+{
+  return 0;
+}
+
+int32_t
+WebrtcMediaDataDecoder::Decode(
+  const webrtc::EncodedImage& inputImage,
+  bool missingFrames,
+  const webrtc::RTPFragmentationHeader* fragmentation,
+  const webrtc::CodecSpecificInfo* codecSpecificInfo,
+  int64_t renderTimeMs)
+{
+  return 0;
+}
+
+int32_t
+WebrtcMediaDataDecoder::RegisterDecodeCompleteCallback(
+  webrtc::DecodedImageCallback* callback)
+{
+  return 0;
+}
+
+int32_t
+WebrtcMediaDataDecoder::Release()
+{
+  return 0;
+}
+
+} // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/media/webrtc/signaling/src/media-conduit/WebrtcMediaDataDecoderCodec.h
@@ -0,0 +1,44 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef WebrtcMediaDataDecoderCodec_h__
+#define WebrtcMediaDataDecoderCodec_h__
+
+#include "MediaConduitInterface.h"
+#include "mozilla/RefPtr.h"
+
+#include "webrtc/modules/video_coding/include/video_codec_interface.h"
+
+namespace mozilla {
+
+class MediaDataDecoder;
+
+class WebrtcMediaDataDecoder : public WebrtcVideoDecoder
+{
+public:
+  WebrtcMediaDataDecoder();
+
+  virtual ~WebrtcMediaDataDecoder();
+
+  // Implement VideoDecoder interface.
+  uint64_t PluginID() const override { return 0; }
+
+  int32_t InitDecode(const webrtc::VideoCodec* codecSettings,
+                     int32_t numberOfCores) override;
+
+  int32_t Decode(const webrtc::EncodedImage& inputImage,
+                 bool missingFrames,
+                 const webrtc::RTPFragmentationHeader* fragmentation,
+                 const webrtc::CodecSpecificInfo* codecSpecificInfo = NULL,
+                 int64_t renderTimeMs = -1) override;
+
+  int32_t RegisterDecodeCompleteCallback(
+    webrtc::DecodedImageCallback* callback) override;
+
+  int32_t Release() override;
+};
+
+} // namespace mozilla
+
+#endif // WebrtcMediaDataDecoderCodec_h__
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -558,16 +558,19 @@ pref("media.peerconnection.capture_delay
 pref("media.getusermedia.playout_delay", 50);
 pref("media.navigator.audio.full_duplex", true);
 #else
 // *BSD, others - merely a guess for now
 pref("media.peerconnection.capture_delay", 50);
 pref("media.getusermedia.playout_delay", 50);
 pref("media.navigator.audio.full_duplex", false);
 #endif
+// Use MediaDataDecoder API for WebRTC, this includes hardware acceleration for
+// decoding.
+pref("media.navigator.mediadatadecoder_enabled", false);
 #endif
 
 pref("dom.webaudio.enabled", true);
 
 #if !defined(ANDROID)
 pref("media.getusermedia.screensharing.enabled", true);
 #endif