Bug 1404997 - P6. Fix constness were applicable. r?pehrsons draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 30 Nov 2017 20:48:48 +0100
changeset 710536 77686b7fcb0a8a5de22a09889199d6932a51dd00
parent 710535 08ca501afd5f337e94abed2470d52a06c5383de6
child 710537 7b82723a59560905027ebe1d43f69bc024092951
push id92845
push userbmo:jyavenard@mozilla.com
push dateSun, 10 Dec 2017 22:43:10 +0000
reviewerspehrsons
bugs1404997
milestone59.0a1
Bug 1404997 - P6. Fix constness were applicable. r?pehrsons MozReview-Commit-ID: JPlZpRz4A9w
media/webrtc/signaling/src/media-conduit/MediaConduitInterface.h
media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
media/webrtc/signaling/src/media-conduit/VideoConduit.h
media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
--- a/media/webrtc/signaling/src/media-conduit/MediaConduitInterface.h
+++ b/media/webrtc/signaling/src/media-conduit/MediaConduitInterface.h
@@ -380,23 +380,24 @@ public:
    * @param video_frame_length: size of the frame
    * @param width, height: dimensions of the frame
    * @param video_type: Type of the video frame - I420, RAW
    * @param captured_time: timestamp when the frame was captured.
    *                       if 0 timestamp is automatcally generated
    * NOTE: ConfigureSendMediaCodec() MUST be called before this function can be invoked
    *       This ensures the inserted video-frames can be transmitted by the conduit
    */
-  virtual MediaConduitErrorCode SendVideoFrame(unsigned char* video_frame,
+  virtual MediaConduitErrorCode SendVideoFrame(const unsigned char* video_frame,
                                                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 SendVideoFrame(
+    const webrtc::VideoFrame& frame) = 0;
 
   virtual MediaConduitErrorCode ConfigureCodecMode(webrtc::VideoCodecMode) = 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
--- a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
+++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
@@ -1687,17 +1687,17 @@ WebrtcVideoConduit::SelectBitrates(
 
 // XXX we need to figure out how to feed back changes in preferred capture
 // resolution to the getUserMedia source.
 // Returns boolean if we've submitted an async change (and took ownership
 // of *frame's data)
 bool
 WebrtcVideoConduit::SelectSendResolution(unsigned short width,
                                          unsigned short height,
-                                         webrtc::VideoFrame* frame) // may be null
+                                         const webrtc::VideoFrame* frame) // may be null
 {
   mCodecMutex.AssertCurrentThreadOwns();
   // XXX This will do bandwidth-resolution adaptation as well - bug 877954
 
   mLastWidth = width;
   mLastHeight = height;
   // Enforce constraints
   if (mCurSendCodecConfig) {
@@ -1789,17 +1789,17 @@ WebrtcVideoConduit::SelectSendResolution
     }
   }
   return false;
 }
 
 nsresult
 WebrtcVideoConduit::ReconfigureSendCodec(unsigned short width,
                                          unsigned short height,
-                                         webrtc::VideoFrame* frame)
+                                         const webrtc::VideoFrame* frame)
 {
   mCodecMutex.AssertCurrentThreadOwns();
 
   // Test in case the stream hasn't started yet!  We could get a frame in
   // before we get around to StartTransmitting(), and that would dispatch a
   // runnable to call this.
   mInReconfig = false;
   if (mSendStream) {
@@ -1834,17 +1834,17 @@ WebrtcVideoConduit::SelectSendFrameRate(
 
       new_framerate = MinIgnoreZero(new_framerate, codecConfig->mEncodingConstraints.maxFps);
     }
   }
   return new_framerate;
 }
 
 MediaConduitErrorCode
-WebrtcVideoConduit::SendVideoFrame(unsigned char* video_buffer,
+WebrtcVideoConduit::SendVideoFrame(const unsigned char* video_buffer,
                                    unsigned int video_length,
                                    unsigned short width,
                                    unsigned short height,
                                    VideoType video_type,
                                    uint64_t capture_time)
 {
   // check for parameter sanity
   if (!video_buffer || video_length == 0 || width == 0 || height == 0) {
@@ -1940,17 +1940,17 @@ WebrtcVideoConduit::OnSinkWantsChanged(
     }
 
     mVideoAdapter->OnResolutionRequest(max_pixel_count,
                                        max_pixel_count_step_up);
   }
 }
 
 MediaConduitErrorCode
-WebrtcVideoConduit::SendVideoFrame(webrtc::VideoFrame& frame)
+WebrtcVideoConduit::SendVideoFrame(const webrtc::VideoFrame& frame)
 {
   // XXX Google uses a "timestamp_aligner" to translate timestamps from the
   // camera via TranslateTimestamp(); we should look at doing the same.  This
   // avoids sampling error when capturing frames, but google had to deal with some
   // broken cameras, include Logitech c920's IIRC.
 
   CSFLogVerbose(LOGTAG, "%s (send SSRC %u (0x%x))", __FUNCTION__,
               mSendStreamConfig.rtp.ssrcs.front(), mSendStreamConfig.rtp.ssrcs.front());
--- a/media/webrtc/signaling/src/media-conduit/VideoConduit.h
+++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.h
@@ -168,27 +168,27 @@ public:
   /**
    * Function to select and change the encoding resolution based on incoming frame size
    * and current available bandwidth.
    * @param width, height: dimensions of the frame
    * @param frame: optional frame to submit for encoding after reconfig
    */
   bool SelectSendResolution(unsigned short width,
                             unsigned short height,
-                            webrtc::VideoFrame* frame);
+                            const webrtc::VideoFrame* frame);
 
   /**
    * Function to reconfigure the current send codec for a different
    * width/height/framerate/etc.
    * @param width, height: dimensions of the frame
    * @param frame: optional frame to submit for encoding after reconfig
    */
   nsresult ReconfigureSendCodec(unsigned short width,
                                 unsigned short height,
-                                webrtc::VideoFrame* frame);
+                                const webrtc::VideoFrame* frame);
 
   /**
    * Function to select and change the encoding frame rate based on incoming frame rate
    * and max-mbps setting.
    * @param current framerate
    * @result new framerate
    */
   unsigned int SelectSendFrameRate(const VideoCodecConfig* codecConfig,
@@ -202,25 +202,26 @@ public:
    * @param video_frame_length: size of the frame
    * @param width, height: dimensions of the frame
    * @param video_type: Type of the video frame - I420, RAW
    * @param captured_time: timestamp when the frame was captured.
    *                       if 0 timestamp is automatcally generated by the engine.
    *NOTE: ConfigureSendMediaCodec() SHOULD be called before this function can be invoked
    *       This ensures the inserted video-frames can be transmitted by the conduit
    */
-  virtual MediaConduitErrorCode SendVideoFrame(unsigned char* video_frame,
+  virtual MediaConduitErrorCode SendVideoFrame(const unsigned char* video_frame,
                                                unsigned int video_frame_length,
                                                unsigned short width,
                                                unsigned short height,
                                                VideoType video_type,
                                                uint64_t capture_time) override;
-  virtual MediaConduitErrorCode SendVideoFrame(webrtc::VideoFrame& frame) override;
+  virtual MediaConduitErrorCode SendVideoFrame(
+    const webrtc::VideoFrame& frame) override;
 
- /**
+  /**
    * webrtc::Transport method implementation
    * ---------------------------------------
    * Webrtc transport implementation to send and receive RTP packet.
    * VideoConduit registers itself as ExternalTransport to the VideoStream
    */
   virtual bool SendRtp(const uint8_t* packet, size_t length,
                        const webrtc::PacketOptions& options) override;
 
--- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
+++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
@@ -81,24 +81,24 @@ namespace mozilla {
 extern mozilla::LogModule*
 AudioLogModule();
 
 class VideoConverterListener
 {
 public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VideoConverterListener)
 
-  virtual void OnVideoFrameConverted(unsigned char* aVideoFrame,
+  virtual void OnVideoFrameConverted(const unsigned char* aVideoFrame,
                                      unsigned int aVideoFrameLength,
                                      unsigned short aWidth,
                                      unsigned short aHeight,
                                      VideoType aVideoType,
                                      uint64_t aCaptureTime) = 0;
 
-  virtual void OnVideoFrameConverted(webrtc::VideoFrame& aVideoFrame) = 0;
+  virtual void OnVideoFrameConverted(const webrtc::VideoFrame& aVideoFrame) = 0;
 
 protected:
   virtual ~VideoConverterListener() {}
 };
 
 // I420 buffer size macros
 #define YSIZE(x, y) (CheckedInt<int>(x) * (y))
 #define CRSIZE(x, y) ((((x) + 1) >> 1) * (((y) + 1) >> 1))
@@ -127,17 +127,17 @@ public:
     , mThrottleCount(0)
     , mThrottleRecord(0)
 #endif
     , mMutex("VideoFrameConverter")
   {
     MOZ_COUNT_CTOR(VideoFrameConverter);
   }
 
-  void QueueVideoChunk(VideoChunk& aChunk, bool aForceBlack)
+  void QueueVideoChunk(const VideoChunk& aChunk, bool aForceBlack)
   {
     if (aChunk.IsNull()) {
       return;
     }
 
     // We get passed duplicate frames every ~10ms even with no frame change.
     int32_t serial = aChunk.mFrame.GetImage()->GetSerial();
     if (serial == mLastImage) {
@@ -283,17 +283,17 @@ protected:
 
     webrtc::VideoFrame video_frame(video_frame_buffer,
                                    aCaptureTime,
                                    aCaptureTime,
                                    webrtc::kVideoRotation_0); // XXX
     VideoFrameConverted(video_frame);
   }
 
-  void VideoFrameConverted(webrtc::VideoFrame& aVideoFrame)
+  void VideoFrameConverted(const webrtc::VideoFrame& aVideoFrame)
   {
     MutexAutoLock lock(mMutex);
 
     for (RefPtr<VideoConverterListener>& listener : mListeners) {
       listener->OnVideoFrameConverted(aVideoFrame);
     }
   }
 
@@ -1374,34 +1374,34 @@ public:
     audio_processing_ = proxy;
   }
 
   void SetVideoFrameConverter(const RefPtr<VideoFrameConverter>& converter)
   {
     converter_ = converter;
   }
 
-  void OnVideoFrameConverted(unsigned char* aVideoFrame,
+  void OnVideoFrameConverted(const unsigned char* aVideoFrame,
                              unsigned int aVideoFrameLength,
                              unsigned short aWidth,
                              unsigned short aHeight,
                              VideoType aVideoType,
                              uint64_t aCaptureTime)
   {
     MOZ_RELEASE_ASSERT(conduit_->type() == MediaSessionConduit::VIDEO);
     static_cast<VideoSessionConduit*>(conduit_.get())
       ->SendVideoFrame(aVideoFrame,
                        aVideoFrameLength,
                        aWidth,
                        aHeight,
                        aVideoType,
                        aCaptureTime);
   }
 
-  void OnVideoFrameConverted(webrtc::VideoFrame& aVideoFrame)
+  void OnVideoFrameConverted(const webrtc::VideoFrame& aVideoFrame)
   {
     MOZ_RELEASE_ASSERT(conduit_->type() == MediaSessionConduit::VIDEO);
     static_cast<VideoSessionConduit*>(conduit_.get())
       ->SendVideoFrame(aVideoFrame);
   }
 
   // Implement MediaStreamTrackListener
   void NotifyQueuedChanges(MediaStreamGraph* aGraph,
@@ -1467,17 +1467,17 @@ public:
 
   void Detach()
   {
     MutexAutoLock lock(mutex_);
 
     listener_ = nullptr;
   }
 
-  void OnVideoFrameConverted(unsigned char* aVideoFrame,
+  void OnVideoFrameConverted(const unsigned char* aVideoFrame,
                              unsigned int aVideoFrameLength,
                              unsigned short aWidth,
                              unsigned short aHeight,
                              VideoType aVideoType,
                              uint64_t aCaptureTime) override
   {
     MutexAutoLock lock(mutex_);
 
@@ -1488,17 +1488,17 @@ public:
     listener_->OnVideoFrameConverted(aVideoFrame,
                                      aVideoFrameLength,
                                      aWidth,
                                      aHeight,
                                      aVideoType,
                                      aCaptureTime);
   }
 
-  void OnVideoFrameConverted(webrtc::VideoFrame& aVideoFrame) override
+  void OnVideoFrameConverted(const webrtc::VideoFrame& aVideoFrame) override
   {
     MutexAutoLock lock(mutex_);
 
     if (!listener_) {
       return;
     }
 
     listener_->OnVideoFrameConverted(aVideoFrame);