Bug 1404997 - P9. Remove unnecessary const_cast. r?pehrsons draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 05 Dec 2017 00:07:52 +0100
changeset 712227 d8a32c4811e957d65ae832c2f9e3a45694399ca4
parent 712226 8a47c2cb3ee76070c536d2d0636dffc9a3842c5c
child 712228 23ca0c1bbb82ea6a43ad02b90fa3e1d56b6075e7
push id93280
push userbmo:jyavenard@mozilla.com
push dateFri, 15 Dec 2017 20:49:10 +0000
reviewerspehrsons
bugs1404997
milestone59.0a1
Bug 1404997 - P9. Remove unnecessary const_cast. r?pehrsons MozReview-Commit-ID: 1XkHmGgPqRM
media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
--- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
+++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
@@ -330,28 +330,26 @@ protected:
                             0);
       }
       return;
     }
 
     ImageFormat format = aImage->GetFormat();
     if (format == ImageFormat::PLANAR_YCBCR) {
       // Cast away constness b/c some of the accessors are non-const
-      PlanarYCbCrImage* yuv = const_cast<PlanarYCbCrImage*>(
-        static_cast<const PlanarYCbCrImage*>(aImage));
-
-      const PlanarYCbCrData* data = yuv->GetData();
+      const PlanarYCbCrData* data =
+        static_cast<const PlanarYCbCrImage*>(aImage)->GetData();
       if (data) {
         uint8_t* y = data->mYChannel;
         uint8_t* cb = data->mCbChannel;
         uint8_t* cr = data->mCrChannel;
         int32_t yStride = data->mYStride;
         int32_t cbCrStride = data->mCbCrStride;
-        uint32_t width = yuv->GetSize().width;
-        uint32_t height = yuv->GetSize().height;
+        uint32_t width = aImage->GetSize().width;
+        uint32_t height = aImage->GetSize().height;
 
         rtc::Callback0<void> callback_unused;
         rtc::scoped_refptr<webrtc::WrappedI420Buffer> video_frame_buffer(
           new rtc::RefCountedObject<webrtc::WrappedI420Buffer>(
             width,
             height,
             y,
             yStride,
@@ -2013,27 +2011,24 @@ MediaPipelineTransmit::PipelineListener:
   }
 
   // TODO(ekr@rtfm.com): For now assume that we have only one
   // track type and it's destined for us
   // See bug 784517
   if (aMedia.GetType() == MediaSegment::AUDIO) {
     MOZ_RELEASE_ASSERT(aRate > 0);
 
-    AudioSegment* audio =
-      const_cast<AudioSegment*>(static_cast<const AudioSegment*>(&aMedia));
-    for (AudioSegment::ChunkIterator iter(*audio); !iter.IsEnded();
+    const AudioSegment* audio = static_cast<const AudioSegment*>(&aMedia);
+    for (AudioSegment::ConstChunkIterator iter(*audio); !iter.IsEnded();
          iter.Next()) {
       mAudioProcessing->QueueAudioChunk(aRate, *iter, mEnabled);
     }
   } else {
-    VideoSegment* video =
-      const_cast<VideoSegment*>(static_cast<const VideoSegment*>(&aMedia));
-    VideoSegment::ChunkIterator iter(*video);
-    for (VideoSegment::ChunkIterator iter(*video); !iter.IsEnded();
+    const VideoSegment* video = static_cast<const VideoSegment*>(&aMedia);
+    for (VideoSegment::ConstChunkIterator iter(*video); !iter.IsEnded();
          iter.Next()) {
       mConverter->QueueVideoChunk(*iter, !mEnabled);
     }
   }
 }
 
 void
 MediaPipelineTransmit::PipelineListener::SetCurrentFrames(