Moved NackModule and VCMPacket to their own targets

Bug: webrtc:9373
Change-Id: I1e882b734dcafb5c633eabf08bb8a1a6a407a251
Reviewed-on: https://webrtc-review.googlesource.com/81744
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Reviewed-by: Åsa Persson <asapersson@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23621}
diff --git a/modules/include/module_common_types.h b/modules/include/module_common_types.h
index c46ca1d..65bb207 100644
--- a/modules/include/module_common_types.h
+++ b/modules/include/module_common_types.h
@@ -268,6 +268,33 @@
 
   virtual ~CallStatsObserver() {}
 };
+
+// Interface used by NackModule and JitterBuffer.
+class NackSender {
+ public:
+  virtual void SendNack(const std::vector<uint16_t>& sequence_numbers) = 0;
+
+ protected:
+  virtual ~NackSender() {}
+};
+
+// Interface used by NackModule and JitterBuffer.
+class KeyFrameRequestSender {
+ public:
+  virtual void RequestKeyFrame() = 0;
+
+ protected:
+  virtual ~KeyFrameRequestSender() {}
+};
+
+// Used to indicate if a received packet contain a complete NALU (or equivalent)
+enum VCMNaluCompleteness {
+  kNaluUnset = 0,     // Packet has not been filled.
+  kNaluComplete = 1,  // Packet can be decoded as is.
+  kNaluStart,         // Packet contain beginning of NALU
+  kNaluIncomplete,    // Packet is not beginning or end of NALU
+  kNaluEnd,           // Packet is the end of a NALU
+};
 }  // namespace webrtc
 
 #endif  // MODULES_INCLUDE_MODULE_COMMON_TYPES_H_
diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn
index dd939ce..18baa68 100644
--- a/modules/video_coding/BUILD.gn
+++ b/modules/video_coding/BUILD.gn
@@ -36,6 +36,46 @@
   }
 }
 
+rtc_static_library("nack_module") {
+  visibility = [ "*" ]
+  sources = [
+    "histogram.cc",
+    "histogram.h",
+    "nack_module.cc",
+    "nack_module.h",
+  ]
+
+  # TODO(jschuh): Bug 1348: fix this warning.
+  configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
+
+  if (!build_with_chromium && is_clang) {
+    # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
+    suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
+  }
+
+  deps = [
+    ":packet",
+    "..:module_api",
+    "../../rtc_base:checks",
+    "../../rtc_base:rtc_base_approved",
+    "../../rtc_base:rtc_numerics",
+    "../../system_wrappers",
+    "../utility:utility",
+  ]
+}
+
+rtc_static_library("packet") {
+  visibility = [ "*" ]
+  sources = [
+    "packet.cc",
+    "packet.h",
+  ]
+  deps = [
+    "..:module_api",
+    "../../:typedefs",
+  ]
+}
+
 rtc_static_library("video_coding") {
   visibility = [ "*" ]
   deps = []
@@ -66,8 +106,6 @@
     "h264_sprop_parameter_sets.h",
     "h264_sps_pps_tracker.cc",
     "h264_sps_pps_tracker.h",
-    "histogram.cc",
-    "histogram.h",
     "include/video_codec_initializer.h",
     "include/video_coding.h",
     "inter_frame_delay.cc",
@@ -83,10 +121,6 @@
     "media_optimization.cc",
     "media_optimization.h",
     "nack_fec_tables.h",
-    "nack_module.cc",
-    "nack_module.h",
-    "packet.cc",
-    "packet.h",
     "packet_buffer.cc",
     "packet_buffer.h",
     "qp_parser.cc",
@@ -121,6 +155,7 @@
   deps += [
     ":codec_globals_headers",
     ":encoded_frame",
+    ":packet",
     ":video_codec_interface",
     ":video_coding_utility",
     ":webrtc_vp8_helpers",
@@ -814,6 +849,8 @@
       ":codec_globals_headers",
       ":encoded_frame",
       ":mock_headers",
+      ":nack_module",
+      ":packet",
       ":video_codec_interface",
       ":video_codecs_test_framework",
       ":video_coding",
diff --git a/modules/video_coding/include/video_coding_defines.h b/modules/video_coding/include/video_coding_defines.h
index ea3e3ec..596e5ca 100644
--- a/modules/video_coding/include/video_coding_defines.h
+++ b/modules/video_coding/include/video_coding_defines.h
@@ -131,22 +131,6 @@
   virtual ~VCMPacketRequestCallback() {}
 };
 
-class NackSender {
- public:
-  virtual void SendNack(const std::vector<uint16_t>& sequence_numbers) = 0;
-
- protected:
-  virtual ~NackSender() {}
-};
-
-class KeyFrameRequestSender {
- public:
-  virtual void RequestKeyFrame() = 0;
-
- protected:
-  virtual ~KeyFrameRequestSender() {}
-};
-
 }  // namespace webrtc
 
 #endif  // MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_DEFINES_H_
diff --git a/modules/video_coding/jitter_buffer.h b/modules/video_coding/jitter_buffer.h
index 2732af8..4908080 100644
--- a/modules/video_coding/jitter_buffer.h
+++ b/modules/video_coding/jitter_buffer.h
@@ -25,7 +25,6 @@
 #include "modules/video_coding/inter_frame_delay.h"
 #include "modules/video_coding/jitter_buffer_common.h"
 #include "modules/video_coding/jitter_estimator.h"
-#include "modules/video_coding/nack_module.h"
 #include "rtc_base/constructormagic.h"
 #include "rtc_base/criticalsection.h"
 #include "rtc_base/thread_annotations.h"
diff --git a/modules/video_coding/jitter_buffer_common.h b/modules/video_coding/jitter_buffer_common.h
index 257ebc0..0ea73ee 100644
--- a/modules/video_coding/jitter_buffer_common.h
+++ b/modules/video_coding/jitter_buffer_common.h
@@ -58,15 +58,6 @@
 };
 
 enum { kH264StartCodeLengthBytes = 4 };
-
-// Used to indicate if a received packet contain a complete NALU (or equivalent)
-enum VCMNaluCompleteness {
-  kNaluUnset = 0,     // Packet has not been filled.
-  kNaluComplete = 1,  // Packet can be decoded as is.
-  kNaluStart,         // Packet contain beginning of NALU
-  kNaluIncomplete,    // Packet is not beginning or end of NALU
-  kNaluEnd,           // Packet is the end of a NALU
-};
 }  // namespace webrtc
 
 #endif  // MODULES_VIDEO_CODING_JITTER_BUFFER_COMMON_H_
diff --git a/modules/video_coding/nack_module.h b/modules/video_coding/nack_module.h
index c18c99f..5640ea8 100644
--- a/modules/video_coding/nack_module.h
+++ b/modules/video_coding/nack_module.h
@@ -16,8 +16,8 @@
 #include <set>
 
 #include "modules/include/module.h"
+#include "modules/include/module_common_types.h"
 #include "modules/video_coding/histogram.h"
-#include "modules/video_coding/include/video_coding_defines.h"
 #include "modules/video_coding/packet.h"
 #include "rtc_base/criticalsection.h"
 #include "rtc_base/numerics/sequence_number_util.h"
diff --git a/modules/video_coding/packet.h b/modules/video_coding/packet.h
index e377fb9..53b69a3 100644
--- a/modules/video_coding/packet.h
+++ b/modules/video_coding/packet.h
@@ -12,7 +12,6 @@
 #define MODULES_VIDEO_CODING_PACKET_H_
 
 #include "modules/include/module_common_types.h"
-#include "modules/video_coding/jitter_buffer_common.h"
 #include "typedefs.h"  // NOLINT(build/include)
 
 namespace webrtc {
diff --git a/modules/video_coding/session_info.cc b/modules/video_coding/session_info.cc
index f78b35c..74db4e7 100644
--- a/modules/video_coding/session_info.cc
+++ b/modules/video_coding/session_info.cc
@@ -9,7 +9,7 @@
  */
 
 #include "modules/video_coding/session_info.h"
-
+#include "modules/video_coding/jitter_buffer_common.h"
 #include "modules/video_coding/packet.h"
 #include "rtc_base/logging.h"
 
diff --git a/video/BUILD.gn b/video/BUILD.gn
index b00ea13..f56a71d 100644
--- a/video/BUILD.gn
+++ b/video/BUILD.gn
@@ -74,6 +74,8 @@
     "../call:video_stream_api",
     "../modules/rtp_rtcp:rtp_rtcp_format",
     "../modules/video_coding:codec_globals_headers",
+    "../modules/video_coding:nack_module",
+    "../modules/video_coding:packet",
     "../modules/video_coding:video_codec_interface",
     "../rtc_base:checks",
     "../rtc_base:stringutils",
@@ -387,6 +389,7 @@
       "../modules/utility",
       "../modules/video_coding",
       "../modules/video_coding:codec_globals_headers",
+      "../modules/video_coding:packet",
       "../modules/video_coding:video_codec_interface",
       "../modules/video_coding:video_coding_utility",
       "../modules/video_coding:webrtc_h264",
diff --git a/video/rtp_video_stream_receiver.cc b/video/rtp_video_stream_receiver.cc
index 589b0da..996154f 100644
--- a/video/rtp_video_stream_receiver.cc
+++ b/video/rtp_video_stream_receiver.cc
@@ -28,6 +28,7 @@
 #include "modules/video_coding/frame_object.h"
 #include "modules/video_coding/h264_sprop_parameter_sets.h"
 #include "modules/video_coding/h264_sps_pps_tracker.h"
+#include "modules/video_coding/nack_module.h"
 #include "modules/video_coding/packet_buffer.h"
 #include "modules/video_coding/video_coding_impl.h"
 #include "rtc_base/checks.h"