Bug 1253499 - Add a getter for VideoConduit's current send config. r?jesup draft
authorAndreas Pehrson <pehrsons@gmail.com>
Tue, 30 May 2017 17:40:58 +0200
changeset 586510 9df28d4c244ae4ea393929dca8eb453fbfa8465a
parent 583638 291a11111bdd05c5cd55dd552da4b1285ceba9b2
child 586511 831dc18176baff5e75cafbb06a28ef14f5e90a86
child 591073 90002482df93f50588dde72820fd53a8d29fadbd
push id61438
push userbmo:pehrson@telenordigital.com
push dateTue, 30 May 2017 15:50:19 +0000
reviewersjesup
bugs1253499
milestone55.0a1
Bug 1253499 - Add a getter for VideoConduit's current send config. r?jesup MozReview-Commit-ID: JGLRcs0kWeg
media/webrtc/signaling/src/media-conduit/MediaConduitInterface.h
media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
media/webrtc/signaling/src/media-conduit/VideoConduit.h
--- a/media/webrtc/signaling/src/media-conduit/MediaConduitInterface.h
+++ b/media/webrtc/signaling/src/media-conduit/MediaConduitInterface.h
@@ -386,16 +386,23 @@ public:
                                                unsigned int video_frame_length,
                                                unsigned short width,
                                                unsigned short height,
                                                VideoType video_type,
                                                uint64_t capture_time) = 0;
   virtual MediaConduitErrorCode SendVideoFrame(webrtc::VideoFrame& frame) = 0;
 
   virtual MediaConduitErrorCode ConfigureCodecMode(webrtc::VideoCodecMode) = 0;
+
+  /**
+   * Writes a copy of the current send codec config to outConfig if the session
+   * has been initialized.
+   */
+  virtual MediaConduitErrorCode CurrentSendCodecConfig(nsAutoPtr<VideoCodecConfig>* outConfig) = 0;
+
   /**
    * Function to configure send codec for the video session
    * @param sendSessionConfig: CodecConfiguration
    * @result: On Success, the video engine is configured with passed in codec for send
    *          On failure, video engine transmit functionality is disabled.
    * NOTE: This API can be invoked multiple time. Invoking this API may involve restarting
    *        transmission sub-system on the engine
    *
@@ -512,22 +519,21 @@ public:
    *       This ensures the decoded samples are ready for reading.
    *
    */
   virtual MediaConduitErrorCode GetAudioFrame(int16_t speechData[],
                                               int32_t samplingFreqHz,
                                               int32_t capture_delay,
                                               int& lengthSamples) = 0;
 
-   /**
-    * Function to configure send codec for the audio session
-    * @param sendSessionConfig: CodecConfiguration
-    * NOTE: See VideoConduit for more information
-    */
-
+  /**
+   * Function to configure send codec for the audio session
+   * @param sendSessionConfig: CodecConfiguration
+   * NOTE: See VideoConduit for more information
+   */
   virtual MediaConduitErrorCode ConfigureSendMediaCodec(const AudioCodecConfig* sendCodecConfig) = 0;
 
    /**
     * Function to configure list of receive codecs for the audio session
     * @param sendSessionConfig: CodecConfiguration
     * NOTE: See VideoConduit for more information
     */
   virtual MediaConduitErrorCode ConfigureRecvMediaCodecs(
--- a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
+++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
@@ -465,27 +465,40 @@ static bool CompatibleH264Config(const w
   if (aEncoderSpecificH264.profile_byte != aCodecConfig.mProfile ||
       aEncoderSpecificH264.constraints != aCodecConfig.mConstraints ||
       aEncoderSpecificH264.packetizationMode != aCodecConfig.mPacketizationMode) {
     return false;
   }
   return true;
 }
 
+MediaConduitErrorCode
+WebrtcVideoConduit::CurrentSendCodecConfig(nsAutoPtr<VideoCodecConfig>* outConfig)
+{
+  CSFLogDebug(logTag, "%s", __FUNCTION__);
+
+  MutexAutoLock lock(mCodecMutex);
+  if (!mCurSendCodecConfig) {
+    return kMediaConduitSessionNotInited;
+  }
+
+  *outConfig = new VideoCodecConfig(*mCurSendCodecConfig);
+  return kMediaConduitNoError;
+}
+
 /**
  * Note: Setting the send-codec on the Video Engine will restart the encoder,
  * sets up new SSRC and reset RTP_RTCP module with the new codec setting.
  *
  * Note: this is called from MainThread, and the codec settings are read on
  * videoframe delivery threads (i.e in SendVideoFrame().  With
  * renegotiation/reconfiguration, this now needs a lock!  Alternatively
  * changes could be queued until the next frame is delivered using an
  * Atomic pointer and swaps.
  */
-
 MediaConduitErrorCode
 WebrtcVideoConduit::ConfigureSendMediaCodec(const VideoCodecConfig* codecConfig)
 {
   CSFLogDebug(logTag, "%s for %s", __FUNCTION__,
     codecConfig ? codecConfig->mName.c_str() : "<null>");
 
   MediaConduitErrorCode condError = kMediaConduitNoError;
 
--- a/media/webrtc/signaling/src/media-conduit/VideoConduit.h
+++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.h
@@ -114,16 +114,22 @@ public:
   virtual MediaConduitErrorCode StopReceiving() override;
   virtual MediaConduitErrorCode StartReceiving() override;
 
   /**
    * Function to configure sending codec mode for different content
    */
   virtual MediaConduitErrorCode ConfigureCodecMode(webrtc::VideoCodecMode) override;
 
+  /**
+   * Writes a copy of the current send codec config to outConfig if the session
+   * has been initialized.
+   */
+  MediaConduitErrorCode CurrentSendCodecConfig(nsAutoPtr<VideoCodecConfig>* outConfig) override;
+
    /**
    * Function to configure send codec for the video session
    * @param sendSessionConfig: CodecConfiguration
    * @result: On Success, the video engine is configured with passed in codec for send
    *          On failure, video engine transmit functionality is disabled.
    * NOTE: This API can be invoked multiple time. Invoking this API may involve restarting
    *        transmission sub-system on the engine.
    */