OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENCODERFACTORY_H_ | 11 #ifndef WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENCODERFACTORY_H_ |
12 #define WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENCODERFACTORY_H_ | 12 #define WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENCODERFACTORY_H_ |
13 | 13 |
14 #include "webrtc/base/refcount.h" | 14 #include <vector> |
| 15 |
15 #include "webrtc/common_types.h" | 16 #include "webrtc/common_types.h" |
16 #include "webrtc/media/base/codec.h" | 17 #include "webrtc/media/base/codec.h" |
17 | 18 |
18 namespace webrtc { | 19 namespace webrtc { |
19 class VideoEncoder; | 20 class VideoEncoder; |
20 } | 21 } |
21 | 22 |
22 namespace cricket { | 23 namespace cricket { |
23 | 24 |
24 class WebRtcVideoEncoderFactory { | 25 class WebRtcVideoEncoderFactory { |
25 public: | 26 public: |
| 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. |
26 struct VideoCodec { | 30 struct VideoCodec { |
27 webrtc::VideoCodecType type; | 31 webrtc::VideoCodecType type; |
28 std::string name; | 32 std::string name; |
29 int max_width; | |
30 int max_height; | |
31 int max_fps; | |
32 | 33 |
33 VideoCodec(webrtc::VideoCodecType t, const std::string& nm, int w, int h, | 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, |
34 int fr) | 41 int fr) |
35 : type(t), name(nm), max_width(w), max_height(h), max_fps(fr) { | 42 : type(t), name(nm) {} |
36 } | |
37 }; | 43 }; |
38 | 44 |
39 virtual ~WebRtcVideoEncoderFactory() {} | 45 virtual ~WebRtcVideoEncoderFactory() {} |
40 | 46 |
| 47 // TODO(magjed): Make these functions pure virtual when every external client |
| 48 // implements it. See http://crbug/webrtc/6402 for more info. |
41 // Caller takes the ownership of the returned object and it should be released | 49 // Caller takes the ownership of the returned object and it should be released |
42 // by calling DestroyVideoEncoder(). | 50 // by calling DestroyVideoEncoder(). |
43 virtual webrtc::VideoEncoder* CreateVideoEncoder( | 51 virtual webrtc::VideoEncoder* CreateVideoEncoder( |
44 webrtc::VideoCodecType type) = 0; | 52 const cricket::VideoCodec& codec); |
45 | 53 |
46 // Returns a list of supported codecs in order of preference. | 54 // Returns a list of supported codecs in order of preference. |
47 virtual const std::vector<VideoCodec>& codecs() const = 0; | 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; |
48 | 67 |
49 // Returns true if encoders created by this factory of the given codec type | 68 // Returns true if encoders created by this factory of the given codec type |
50 // will use internal camera sources, meaning that they don't require/expect | 69 // will use internal camera sources, meaning that they don't require/expect |
51 // frames to be delivered via webrtc::VideoEncoder::Encode. This flag is used | 70 // frames to be delivered via webrtc::VideoEncoder::Encode. This flag is used |
52 // as the internal_source parameter to | 71 // as the internal_source parameter to |
53 // webrtc::ViEExternalCodec::RegisterExternalSendCodec. | 72 // webrtc::ViEExternalCodec::RegisterExternalSendCodec. |
54 virtual bool EncoderTypeHasInternalSource(webrtc::VideoCodecType type) const { | 73 virtual bool EncoderTypeHasInternalSource(webrtc::VideoCodecType type) const { |
55 return false; | 74 return false; |
56 } | 75 } |
57 | 76 |
58 virtual void DestroyVideoEncoder(webrtc::VideoEncoder* encoder) = 0; | 77 virtual void DestroyVideoEncoder(webrtc::VideoEncoder* encoder) = 0; |
| 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_; |
59 }; | 85 }; |
60 | 86 |
61 } // namespace cricket | 87 } // namespace cricket |
62 | 88 |
63 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENCODERFACTORY_H_ | 89 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOENCODERFACTORY_H_ |
OLD | NEW |