Cleanup of unused RTP structs and packetizer for stereo codec

This CL is a followup to https://webrtc-review.googlesource.com/c/src/+/38481.
With the new approach we can just use the generic RTP packetizer to pass frames
over the wire as the specific info is contained within the bitstream. This makes
the new codec more modular and reduces its footprint.

Bug: webrtc:7671
Change-Id: Ib07f72a9d338e3cbfdbf39cba9891a959b5f7552
Reviewed-on: https://webrtc-review.googlesource.com/43220
Reviewed-by: Niklas Enbom <niklas.enbom@webrtc.org>
Commit-Queue: Emircan Uysaler <emircan@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21753}
diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn
index d493e4e..05aa634 100644
--- a/modules/video_coding/BUILD.gn
+++ b/modules/video_coding/BUILD.gn
@@ -160,7 +160,6 @@
   sources = [
     "codecs/h264/include/h264_globals.h",
     "codecs/interface/common_constants.h",
-    "codecs/stereo/include/stereo_globals.h",
     "codecs/vp8/include/vp8_globals.h",
     "codecs/vp9/include/vp9_globals.h",
   ]
diff --git a/modules/video_coding/codecs/stereo/include/stereo_globals.h b/modules/video_coding/codecs/stereo/include/stereo_globals.h
deleted file mode 100644
index 9f9ad0e..0000000
--- a/modules/video_coding/codecs/stereo/include/stereo_globals.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- *  Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-#ifndef MODULES_VIDEO_CODING_CODECS_STEREO_INCLUDE_STEREO_GLOBALS_H_
-#define MODULES_VIDEO_CODING_CODECS_STEREO_INCLUDE_STEREO_GLOBALS_H_
-
-namespace webrtc {
-
-struct StereoIndices {
-  uint8_t frame_index;
-  uint8_t frame_count;
-  uint16_t picture_index;
-};
-
-}  // namespace webrtc
-
-#endif  // MODULES_VIDEO_CODING_CODECS_STEREO_INCLUDE_STEREO_GLOBALS_H_
diff --git a/modules/video_coding/codecs/stereo/stereo_encoder_adapter.cc b/modules/video_coding/codecs/stereo/stereo_encoder_adapter.cc
index b44165e..3c1cc53 100644
--- a/modules/video_coding/codecs/stereo/stereo_encoder_adapter.cc
+++ b/modules/video_coding/codecs/stereo/stereo_encoder_adapter.cc
@@ -212,8 +212,6 @@
     const EncodedImage& encodedImage,
     const CodecSpecificInfo* codecSpecificInfo,
     const RTPFragmentationHeader* fragmentation) {
-  CodecSpecificInfo codec_info = *codecSpecificInfo;
-  codec_info.codecType = kVideoCodecStereo;
   const auto& stashed_image_itr = stashed_images_.find(encodedImage._timeStamp);
   const auto& stashed_image_next_itr = std::next(stashed_image_itr, 1);
   RTC_DCHECK(stashed_image_itr != stashed_images_.end());
@@ -246,6 +244,10 @@
         delete[] combined_image_._buffer;
       combined_image_ =
           MultiplexEncodedImagePacker::PackAndRelease(iter->second);
+
+      CodecSpecificInfo codec_info = *codecSpecificInfo;
+      codec_info.codecType = kVideoCodecStereo;
+      codec_info.codecSpecific.generic.simulcast_idx = 0;
       encoded_complete_callback_->OnEncodedImage(combined_image_, &codec_info,
                                                  fragmentation);
       iter++;
diff --git a/modules/video_coding/encoded_frame.cc b/modules/video_coding/encoded_frame.cc
index 2d8716c..9950012 100644
--- a/modules/video_coding/encoded_frame.cc
+++ b/modules/video_coding/encoded_frame.cc
@@ -193,29 +193,8 @@
         _codecSpecificInfo.codecType = kVideoCodecH264;
         break;
       }
-      case kRtpVideoStereo: {
-        _codecSpecificInfo.codecType = kVideoCodecStereo;
-        VideoCodecType associated_codec_type = kVideoCodecUnknown;
-        switch (header->codecHeader.stereo.associated_codec_type) {
-          case kRtpVideoVp8:
-            associated_codec_type = kVideoCodecVP8;
-            break;
-          case kRtpVideoVp9:
-            associated_codec_type = kVideoCodecVP9;
-            break;
-          case kRtpVideoH264:
-            associated_codec_type = kVideoCodecH264;
-            break;
-          default:
-            RTC_NOTREACHED();
-        }
-        _codecSpecificInfo.codecSpecific.stereo.associated_codec_type =
-            associated_codec_type;
-        _codecSpecificInfo.codecSpecific.stereo.indices =
-            header->codecHeader.stereo.indices;
-        break;
-      }
-      default: {
+      case kRtpVideoNone:
+      case kRtpVideoGeneric: {
         _codecSpecificInfo.codecType = kVideoCodecUnknown;
         break;
       }
diff --git a/modules/video_coding/frame_object.cc b/modules/video_coding/frame_object.cc
index 6eb28de..6a31cfd 100644
--- a/modules/video_coding/frame_object.cc
+++ b/modules/video_coding/frame_object.cc
@@ -43,14 +43,9 @@
   frame_type_ = first_packet->frameType;
   codec_type_ = first_packet->codec;
 
-  // Stereo codec appends CopyCodecSpecific to last packet to avoid copy.
-  VCMPacket* packet_with_codec_specific =
-      codec_type_ == kVideoCodecStereo ? packet_buffer_->GetPacket(last_seq_num)
-                                       : first_packet;
-
   // TODO(philipel): Remove when encoded image is replaced by FrameObject.
   // VCMEncodedFrame members
-  CopyCodecSpecific(&packet_with_codec_specific->video_header);
+  CopyCodecSpecific(&first_packet->video_header);
   _completeFrame = true;
   _payloadType = first_packet->payloadType;
   _timeStamp = first_packet->timestamp;
diff --git a/modules/video_coding/include/video_codec_interface.h b/modules/video_coding/include/video_codec_interface.h
index ef52d8bf..6616053 100644
--- a/modules/video_coding/include/video_codec_interface.h
+++ b/modules/video_coding/include/video_codec_interface.h
@@ -73,17 +73,11 @@
   H264PacketizationMode packetization_mode;
 };
 
-struct CodecSpecificInfoStereo {
-  VideoCodecType associated_codec_type;
-  StereoIndices indices;
-};
-
 union CodecSpecificInfoUnion {
   CodecSpecificInfoGeneric generic;
   CodecSpecificInfoVP8 VP8;
   CodecSpecificInfoVP9 VP9;
   CodecSpecificInfoH264 H264;
-  CodecSpecificInfoStereo stereo;
 };
 
 // Note: if any pointers are added to this struct or its sub-structs, it
diff --git a/modules/video_coding/packet.cc b/modules/video_coding/packet.cc
index 9ae5ba0..f176194 100644
--- a/modules/video_coding/packet.cc
+++ b/modules/video_coding/packet.cc
@@ -133,9 +133,6 @@
       }
       codec = kVideoCodecH264;
       return;
-    case kRtpVideoStereo:
-      codec = kVideoCodecStereo;
-      return;
     case kRtpVideoGeneric:
       codec = kVideoCodecGeneric;
       return;