henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
kjellander | 1afca73 | 2016-02-07 20:46:45 -0800 | [diff] [blame] | 2 | * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3 | * |
kjellander | 1afca73 | 2016-02-07 20:46:45 -0800 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
kjellander@webrtc.org | 5ad1297 | 2016-02-12 06:39:40 +0100 | [diff] [blame] | 11 | #ifndef WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENCODERFACTORY_H_ |
| 12 | #define WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENCODERFACTORY_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 13 | |
magjed | 1e45cc6 | 2016-10-28 07:43:45 -0700 | [diff] [blame] | 14 | #include <vector> |
| 15 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 16 | #include "webrtc/common_types.h" |
kjellander | a96e2d7 | 2016-02-04 23:52:28 -0800 | [diff] [blame] | 17 | #include "webrtc/media/base/codec.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 18 | |
| 19 | namespace webrtc { |
| 20 | class VideoEncoder; |
| 21 | } |
| 22 | |
| 23 | namespace cricket { |
| 24 | |
| 25 | class WebRtcVideoEncoderFactory { |
| 26 | public: |
magjed | 1e45cc6 | 2016-10-28 07:43:45 -0700 | [diff] [blame] | 27 | // This VideoCodec class is deprecated. Use cricket::VideoCodec directly |
| 28 | // instead and the corresponding factory function. See |
| 29 | // http://crbug/webrtc/6402 for more info. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 30 | struct VideoCodec { |
| 31 | webrtc::VideoCodecType type; |
| 32 | std::string name; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 33 | |
magjed | 1e45cc6 | 2016-10-28 07:43:45 -0700 | [diff] [blame] | 34 | VideoCodec(webrtc::VideoCodecType t, const std::string& nm) |
| 35 | : type(t), name(nm) {} |
| 36 | |
| 37 | VideoCodec(webrtc::VideoCodecType t, |
| 38 | const std::string& nm, |
| 39 | int w, |
| 40 | int h, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 41 | int fr) |
magjed | 1e45cc6 | 2016-10-28 07:43:45 -0700 | [diff] [blame] | 42 | : type(t), name(nm) {} |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 43 | }; |
| 44 | |
buildbot@webrtc.org | 3c16d8b | 2014-10-13 06:35:10 +0000 | [diff] [blame] | 45 | virtual ~WebRtcVideoEncoderFactory() {} |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 46 | |
magjed | 1e45cc6 | 2016-10-28 07:43:45 -0700 | [diff] [blame] | 47 | // TODO(magjed): Make these functions pure virtual when every external client |
| 48 | // implements it. See http://crbug/webrtc/6402 for more info. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 49 | // Caller takes the ownership of the returned object and it should be released |
| 50 | // by calling DestroyVideoEncoder(). |
| 51 | virtual webrtc::VideoEncoder* CreateVideoEncoder( |
magjed | 1e45cc6 | 2016-10-28 07:43:45 -0700 | [diff] [blame] | 52 | const cricket::VideoCodec& codec); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 53 | |
| 54 | // Returns a list of supported codecs in order of preference. |
magjed | 1e45cc6 | 2016-10-28 07:43:45 -0700 | [diff] [blame] | 55 | virtual const std::vector<cricket::VideoCodec>& supported_codecs() const; |
| 56 | |
| 57 | // Caller takes the ownership of the returned object and it should be released |
| 58 | // by calling DestroyVideoEncoder(). |
| 59 | // Deprecated: Use cricket::VideoCodec as argument instead. See |
| 60 | // http://crbug/webrtc/6402 for more info. |
| 61 | virtual webrtc::VideoEncoder* CreateVideoEncoder(webrtc::VideoCodecType type); |
| 62 | |
| 63 | // Returns a list of supported codecs in order of preference. |
| 64 | // Deprecated: Return cricket::VideoCodecs instead. See |
| 65 | // http://crbug/webrtc/6402 for more info. |
| 66 | virtual const std::vector<VideoCodec>& codecs() const; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 67 | |
pthatcher@webrtc.org | 52cd828 | 2015-03-18 02:24:43 +0000 | [diff] [blame] | 68 | // Returns true if encoders created by this factory of the given codec type |
| 69 | // will use internal camera sources, meaning that they don't require/expect |
| 70 | // frames to be delivered via webrtc::VideoEncoder::Encode. This flag is used |
| 71 | // as the internal_source parameter to |
| 72 | // webrtc::ViEExternalCodec::RegisterExternalSendCodec. |
| 73 | virtual bool EncoderTypeHasInternalSource(webrtc::VideoCodecType type) const { |
| 74 | return false; |
| 75 | } |
| 76 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 77 | virtual void DestroyVideoEncoder(webrtc::VideoEncoder* encoder) = 0; |
magjed | 1e45cc6 | 2016-10-28 07:43:45 -0700 | [diff] [blame] | 78 | |
| 79 | private: |
| 80 | // TODO(magjed): Remove these. They are necessary in order to return a const |
| 81 | // reference to a std::vector in the default implementations of codecs() and |
| 82 | // supported_codecs(). See http://crbug/webrtc/6402 for more info. |
| 83 | mutable std::vector<VideoCodec> encoder_codecs_; |
| 84 | mutable std::vector<cricket::VideoCodec> codecs_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 85 | }; |
| 86 | |
| 87 | } // namespace cricket |
| 88 | |
kjellander@webrtc.org | 5ad1297 | 2016-02-12 06:39:40 +0100 | [diff] [blame] | 89 | #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENCODERFACTORY_H_ |