Reland of Move video_encoder.h and video_decoder.h to /api and create GN targets for them (patchset #1 id:1 of https://codereview.webrtc.org/2794033002/ )

Reason for revert:
Reland with temporary deprecated API to not break chromium and google3.

Original issue's description:
> Revert of Move video_encoder.h and video_decoder.h to /api and create GN targets for them (patchset #8 id:140001 of https://codereview.webrtc.org/2780943003/ )
>
> Reason for revert:
> Suspect of breaking Chrome FYI bots.
>
> See
> https://build.chromium.org/p/chromium.webrtc.fyi/builders/Mac%20Builder/builds/23065
> https://build.chromium.org/p/chromium.webrtc.fyi/builders/Android%20Builder
>
> Example logs:
> ../../content/renderer/media/gpu/rtc_video_encoder_unittest.cc:18:46: fatal error: third_party/webrtc/video_encoder.h: No such file or directory
>  #include "third_party/webrtc/video_encoder.h"
>                                               ^
>
> Original issue's description:
> > Move video_encoder.h and video_decoder.h to /api and create GN targets for them
> >
> > BUG=webrtc:5881
> > # Because PRESUBMIT ignores LINT blacklist for moved files and these
> > # headers have some not easy to resolve issues.
> > NOPRESUBMIT=True
> >
> > Review-Url: https://codereview.webrtc.org/2780943003
> > Cr-Commit-Position: refs/heads/master@{#17511}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/c42f54057050c933008a49d57582577bfb9aed25
>
> TBR=solenberg@webrtc.org,sprang@webrtc.org,ilnik@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5881
>
> Review-Url: https://codereview.webrtc.org/2794033002
> Cr-Commit-Position: refs/heads/master@{#17514}
> Committed: https://chromium.googlesource.com/external/webrtc/+/716d7ac5c1ed6e392e264b34065800bbf03772b3

TBR=solenberg@webrtc.org,sprang@webrtc.org,guidou@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:5881

Review-Url: https://codereview.webrtc.org/2795163002
Cr-Commit-Position: refs/heads/master@{#17537}
diff --git a/webrtc/api/video_codecs/BUILD.gn b/webrtc/api/video_codecs/BUILD.gn
new file mode 100644
index 0000000..befd065
--- /dev/null
+++ b/webrtc/api/video_codecs/BUILD.gn
@@ -0,0 +1,28 @@
+# 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.
+
+import("../../webrtc.gni")
+if (is_android) {
+  import("//build/config/android/config.gni")
+  import("//build/config/android/rules.gni")
+}
+
+rtc_source_set("video_codecs_api") {
+  sources = [
+    "video_decoder.h",
+    "video_encoder.h",
+  ]
+
+  deps = [
+    # TODO(ilnik): Add dependency on webrtc/video_frame.h when it will have it's
+    # own build target.
+
+    "../..:webrtc_common",
+    "../../base:rtc_base_approved",
+  ]
+}
diff --git a/webrtc/api/video_codecs/video_decoder.h b/webrtc/api/video_codecs/video_decoder.h
new file mode 100644
index 0000000..ba62822
--- /dev/null
+++ b/webrtc/api/video_codecs/video_decoder.h
@@ -0,0 +1,86 @@
+/*
+ *  Copyright (c) 2014 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 WEBRTC_API_VIDEO_CODECS_VIDEO_DECODER_H_
+#define WEBRTC_API_VIDEO_CODECS_VIDEO_DECODER_H_
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "webrtc/common_types.h"
+#include "webrtc/typedefs.h"
+#include "webrtc/video_frame.h"
+
+namespace webrtc {
+
+class RTPFragmentationHeader;
+// TODO(pbos): Expose these through a public (root) header or change these APIs.
+struct CodecSpecificInfo;
+class VideoCodec;
+
+class DecodedImageCallback {
+ public:
+  virtual ~DecodedImageCallback() {}
+
+  virtual int32_t Decoded(VideoFrame& decodedImage) = 0;
+  // Provides an alternative interface that allows the decoder to specify the
+  // decode time excluding waiting time for any previous pending frame to
+  // return. This is necessary for breaking positive feedback in the delay
+  // estimation when the decoder has a single output buffer.
+  virtual int32_t Decoded(VideoFrame& decodedImage, int64_t decode_time_ms) {
+    // The default implementation ignores custom decode time value.
+    return Decoded(decodedImage);
+  }
+  // TODO(sakal): Remove other implementations when upstream projects have been
+  // updated.
+  virtual void Decoded(VideoFrame& decodedImage,
+                       rtc::Optional<int32_t> decode_time_ms,
+                       rtc::Optional<uint8_t> qp) {
+    Decoded(decodedImage,
+            decode_time_ms ? static_cast<int32_t>(*decode_time_ms) : -1);
+  }
+
+  virtual int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId) {
+    return -1;
+  }
+
+  virtual int32_t ReceivedDecodedFrame(const uint64_t pictureId) { return -1; }
+};
+
+class VideoDecoder {
+ public:
+  virtual ~VideoDecoder() {}
+
+  virtual int32_t InitDecode(const VideoCodec* codec_settings,
+                             int32_t number_of_cores) = 0;
+
+  virtual int32_t Decode(const EncodedImage& input_image,
+                         bool missing_frames,
+                         const RTPFragmentationHeader* fragmentation,
+                         const CodecSpecificInfo* codec_specific_info = NULL,
+                         int64_t render_time_ms = -1) = 0;
+
+  virtual int32_t RegisterDecodeCompleteCallback(
+      DecodedImageCallback* callback) = 0;
+
+  virtual int32_t Release() = 0;
+
+  // Returns true if the decoder prefer to decode frames late.
+  // That is, it can not decode infinite number of frames before the decoded
+  // frame is consumed.
+  virtual bool PrefersLateDecoding() const { return true; }
+
+  virtual const char* ImplementationName() const { return "unknown"; }
+};
+
+}  // namespace webrtc
+
+#endif  // WEBRTC_API_VIDEO_CODECS_VIDEO_DECODER_H_
diff --git a/webrtc/api/video_codecs/video_encoder.h b/webrtc/api/video_codecs/video_encoder.h
new file mode 100644
index 0000000..969de43
--- /dev/null
+++ b/webrtc/api/video_codecs/video_encoder.h
@@ -0,0 +1,192 @@
+/*
+ *  Copyright (c) 2014 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 WEBRTC_API_VIDEO_CODECS_VIDEO_ENCODER_H_
+#define WEBRTC_API_VIDEO_CODECS_VIDEO_ENCODER_H_
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "webrtc/base/checks.h"
+#include "webrtc/common_types.h"
+#include "webrtc/typedefs.h"
+#include "webrtc/video_frame.h"
+#include "webrtc/base/optional.h"
+
+namespace webrtc {
+
+class RTPFragmentationHeader;
+// TODO(pbos): Expose these through a public (root) header or change these APIs.
+struct CodecSpecificInfo;
+class VideoCodec;
+
+class EncodedImageCallback {
+ public:
+  virtual ~EncodedImageCallback() {}
+
+  struct Result {
+    enum Error {
+      OK,
+
+      // Failed to send the packet.
+      ERROR_SEND_FAILED,
+    };
+
+    Result(Error error) : error(error) {}
+    Result(Error error, uint32_t frame_id) : error(error), frame_id(frame_id) {}
+
+    Error error;
+
+    // Frame ID assigned to the frame. The frame ID should be the same as the ID
+    // seen by the receiver for this frame. RTP timestamp of the frame is used
+    // as frame ID when RTP is used to send video. Must be used only when
+    // error=OK.
+    uint32_t frame_id = 0;
+
+    // Tells the encoder that the next frame is should be dropped.
+    bool drop_next_frame = false;
+  };
+
+  // Callback function which is called when an image has been encoded.
+  virtual Result OnEncodedImage(
+      const EncodedImage& encoded_image,
+      const CodecSpecificInfo* codec_specific_info,
+      const RTPFragmentationHeader* fragmentation) = 0;
+
+  virtual void OnDroppedFrame() {}
+};
+
+class VideoEncoder {
+ public:
+  enum EncoderType {
+    kH264,
+    kVp8,
+    kVp9,
+    kUnsupportedCodec,
+  };
+  struct QpThresholds {
+    QpThresholds(int l, int h) : low(l), high(h) {}
+    QpThresholds() : low(-1), high(-1) {}
+    int low;
+    int high;
+  };
+  struct ScalingSettings {
+    ScalingSettings(bool on, int low, int high)
+        : enabled(on),
+          thresholds(rtc::Optional<QpThresholds>(QpThresholds(low, high))) {}
+    explicit ScalingSettings(bool on) : enabled(on) {}
+    const bool enabled;
+    const rtc::Optional<QpThresholds> thresholds;
+  };
+  static VideoEncoder* Create(EncoderType codec_type);
+  // Returns true if this type of encoder can be created using
+  // VideoEncoder::Create.
+  static bool IsSupportedSoftware(EncoderType codec_type);
+  static EncoderType CodecToEncoderType(VideoCodecType codec_type);
+
+  static VideoCodecVP8 GetDefaultVp8Settings();
+  static VideoCodecVP9 GetDefaultVp9Settings();
+  static VideoCodecH264 GetDefaultH264Settings();
+
+  virtual ~VideoEncoder() {}
+
+  // Initialize the encoder with the information from the codecSettings
+  //
+  // Input:
+  //          - codec_settings    : Codec settings
+  //          - number_of_cores   : Number of cores available for the encoder
+  //          - max_payload_size  : The maximum size each payload is allowed
+  //                                to have. Usually MTU - overhead.
+  //
+  // Return value                  : Set bit rate if OK
+  //                                 <0 - Errors:
+  //                                  WEBRTC_VIDEO_CODEC_ERR_PARAMETER
+  //                                  WEBRTC_VIDEO_CODEC_ERR_SIZE
+  //                                  WEBRTC_VIDEO_CODEC_LEVEL_EXCEEDED
+  //                                  WEBRTC_VIDEO_CODEC_MEMORY
+  //                                  WEBRTC_VIDEO_CODEC_ERROR
+  virtual int32_t InitEncode(const VideoCodec* codec_settings,
+                             int32_t number_of_cores,
+                             size_t max_payload_size) = 0;
+
+  // Register an encode complete callback object.
+  //
+  // Input:
+  //          - callback         : Callback object which handles encoded images.
+  //
+  // Return value                : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise.
+  virtual int32_t RegisterEncodeCompleteCallback(
+      EncodedImageCallback* callback) = 0;
+
+  // Free encoder memory.
+  // Return value                : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise.
+  virtual int32_t Release() = 0;
+
+  // Encode an I420 image (as a part of a video stream). The encoded image
+  // will be returned to the user through the encode complete callback.
+  //
+  // Input:
+  //          - frame             : Image to be encoded
+  //          - frame_types       : Frame type to be generated by the encoder.
+  //
+  // Return value                 : WEBRTC_VIDEO_CODEC_OK if OK
+  //                                <0 - Errors:
+  //                                  WEBRTC_VIDEO_CODEC_ERR_PARAMETER
+  //                                  WEBRTC_VIDEO_CODEC_MEMORY
+  //                                  WEBRTC_VIDEO_CODEC_ERROR
+  //                                  WEBRTC_VIDEO_CODEC_TIMEOUT
+  virtual int32_t Encode(const VideoFrame& frame,
+                         const CodecSpecificInfo* codec_specific_info,
+                         const std::vector<FrameType>* frame_types) = 0;
+
+  // Inform the encoder of the new packet loss rate and the round-trip time of
+  // the network.
+  //
+  // Input:
+  //          - packet_loss : Fraction lost
+  //                          (loss rate in percent = 100 * packetLoss / 255)
+  //          - rtt         : Round-trip time in milliseconds
+  // Return value           : WEBRTC_VIDEO_CODEC_OK if OK
+  //                          <0 - Errors: WEBRTC_VIDEO_CODEC_ERROR
+  virtual int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) = 0;
+
+  // Inform the encoder about the new target bit rate.
+  //
+  // Input:
+  //          - bitrate         : New target bit rate
+  //          - framerate       : The target frame rate
+  //
+  // Return value                : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise.
+  virtual int32_t SetRates(uint32_t bitrate, uint32_t framerate) {
+    RTC_NOTREACHED() << "SetRate(uint32_t, uint32_t) is deprecated.";
+    return -1;
+  }
+
+  // Default fallback: Just use the sum of bitrates as the single target rate.
+  // TODO(sprang): Remove this default implementation when we remove SetRates().
+  virtual int32_t SetRateAllocation(const BitrateAllocation& allocation,
+                                    uint32_t framerate) {
+    return SetRates(allocation.get_sum_kbps(), framerate);
+  }
+
+  // Any encoder implementation wishing to use the WebRTC provided
+  // quality scaler must implement this method.
+  virtual ScalingSettings GetScalingSettings() const {
+    return ScalingSettings(false);
+  }
+
+  virtual int32_t SetPeriodicKeyFrames(bool enable) { return -1; }
+  virtual bool SupportsNativeHandle() const { return false; }
+  virtual const char* ImplementationName() const { return "unknown"; }
+};
+
+}  // namespace webrtc
+#endif  // WEBRTC_API_VIDEO_CODECS_VIDEO_ENCODER_H_