Generalize SimulcastEncoderAdapter, use for H264 & VP8.

* Move SimulcastEncoderAdapter out under modules/video_coding
* Move SimulcastRateAllocator back out to modules/video_coding/utility
* Move TemporalLayers and ScreenshareLayers to modules/video_coding/utility
* Move any VP8 specific code - such as temporal layer bitrate budgeting -
  under codec type dependent conditionals.
* Plumb the simulcast index for H264 in the codec specific and RTP format data structures.

TBR=sprang@webrtc.org,stefan@webrtc.org,titovartem@webrtc.org

Bug: webrtc:5840
Change-Id: I2d3b130622dd7ceec5528f3ab6c46f109e6bafb8
Reviewed-on: https://webrtc-review.googlesource.com/84743
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23715}
diff --git a/modules/video_coding/video_coding_impl.cc b/modules/video_coding/video_coding_impl.cc
index 1127b0f..aa9a0d5 100644
--- a/modules/video_coding/video_coding_impl.cc
+++ b/modules/video_coding/video_coding_impl.cc
@@ -16,7 +16,6 @@
 #include "common_types.h"  // NOLINT(build/include)
 #include "common_video/include/video_bitrate_allocator.h"
 #include "common_video/libyuv/include/webrtc_libyuv.h"
-#include "modules/video_coding/codecs/vp8/temporal_layers.h"
 #include "modules/video_coding/encoded_frame.h"
 #include "modules/video_coding/include/video_codec_initializer.h"
 #include "modules/video_coding/include/video_codec_interface.h"
@@ -105,17 +104,16 @@
   int32_t RegisterSendCodec(const VideoCodec* sendCodec,
                             uint32_t numberOfCores,
                             uint32_t maxPayloadSize) override {
-    if (sendCodec != nullptr && sendCodec->codecType == kVideoCodecVP8) {
-      // Set up a rate allocator and temporal layers factory for this vp8
+    if (sendCodec != nullptr && ((sendCodec->codecType == kVideoCodecVP8) ||
+                                 (sendCodec->codecType == kVideoCodecH264))) {
+      // Set up a rate allocator and temporal layers factory for this codec
       // instance. The codec impl will have a raw pointer to the TL factory,
       // and will call it when initializing. Since this can happen
       // asynchronously keep the instance alive until destruction or until a
       // new send codec is registered.
-      VideoCodec vp8_codec = *sendCodec;
-      rate_allocator_ =
-          VideoCodecInitializer::CreateBitrateAllocator(vp8_codec);
-      return sender_.RegisterSendCodec(&vp8_codec, numberOfCores,
-                                       maxPayloadSize);
+      VideoCodec codec = *sendCodec;
+      rate_allocator_ = VideoCodecInitializer::CreateBitrateAllocator(codec);
+      return sender_.RegisterSendCodec(&codec, numberOfCores, maxPayloadSize);
     }
     return sender_.RegisterSendCodec(sendCodec, numberOfCores, maxPayloadSize);
   }