| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 | 11 |
| 12 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_ENCODER_ADAPTER_H_ | 12 #ifndef WEBRTC_MEDIA_ENGINE_SIMULCAST_ENCODER_ADAPTER_H_ |
| 13 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_ENCODER_ADAPTER_H_ | 13 #define WEBRTC_MEDIA_ENGINE_SIMULCAST_ENCODER_ADAPTER_H_ |
| 14 | 14 |
| 15 #include <memory> | 15 #include <memory> |
| 16 #include <stack> | 16 #include <stack> |
| 17 #include <string> | 17 #include <string> |
| 18 #include <utility> | 18 #include <utility> |
| 19 #include <vector> | 19 #include <vector> |
| 20 | 20 |
| 21 #include "webrtc/base/atomicops.h" | 21 #include "webrtc/base/atomicops.h" |
| 22 #include "webrtc/base/sequenced_task_checker.h" | 22 #include "webrtc/base/sequenced_task_checker.h" |
| 23 #include "webrtc/media/engine/webrtcvideoencoderfactory.h" |
| 23 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" | 24 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" |
| 24 | 25 |
| 25 namespace webrtc { | 26 namespace webrtc { |
| 26 | 27 |
| 27 class SimulcastRateAllocator; | 28 class SimulcastRateAllocator; |
| 28 | 29 |
| 29 // TODO(brandtr): Remove this class and replace its use with a | |
| 30 // WebRtcVideoEncoderFactory. | |
| 31 class VideoEncoderFactory { | |
| 32 public: | |
| 33 virtual VideoEncoder* Create() = 0; | |
| 34 virtual void Destroy(VideoEncoder* encoder) = 0; | |
| 35 virtual ~VideoEncoderFactory() {} | |
| 36 }; | |
| 37 | |
| 38 // SimulcastEncoderAdapter implements simulcast support by creating multiple | 30 // SimulcastEncoderAdapter implements simulcast support by creating multiple |
| 39 // webrtc::VideoEncoder instances with the given VideoEncoderFactory. | 31 // webrtc::VideoEncoder instances with the given VideoEncoderFactory. |
| 40 // The object is created and destroyed on the worker thread, but all public | 32 // The object is created and destroyed on the worker thread, but all public |
| 41 // interfaces should be called from the encoder task queue. | 33 // interfaces should be called from the encoder task queue. |
| 42 class SimulcastEncoderAdapter : public VP8Encoder { | 34 class SimulcastEncoderAdapter : public VP8Encoder { |
| 43 public: | 35 public: |
| 44 // TODO(brandtr): Make it clear that the ownership of |factory| is transferred | 36 explicit SimulcastEncoderAdapter(cricket::WebRtcVideoEncoderFactory* factory); |
| 45 // by only accepting a std::unique_ptr<VideoEncoderFactory> here. | |
| 46 explicit SimulcastEncoderAdapter(VideoEncoderFactory* factory); | |
| 47 virtual ~SimulcastEncoderAdapter(); | 37 virtual ~SimulcastEncoderAdapter(); |
| 48 | 38 |
| 49 // Implements VideoEncoder. | 39 // Implements VideoEncoder. |
| 50 int Release() override; | 40 int Release() override; |
| 51 int InitEncode(const VideoCodec* inst, | 41 int InitEncode(const VideoCodec* inst, |
| 52 int number_of_cores, | 42 int number_of_cores, |
| 53 size_t max_payload_size) override; | 43 size_t max_payload_size) override; |
| 54 int Encode(const VideoFrame& input_image, | 44 int Encode(const VideoFrame& input_image, |
| 55 const CodecSpecificInfo* codec_specific_info, | 45 const CodecSpecificInfo* codec_specific_info, |
| 56 const std::vector<FrameType>* frame_types) override; | 46 const std::vector<FrameType>* frame_types) override; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 int stream_index, | 90 int stream_index, |
| 101 uint32_t start_bitrate_kbps, | 91 uint32_t start_bitrate_kbps, |
| 102 bool highest_resolution_stream, | 92 bool highest_resolution_stream, |
| 103 webrtc::VideoCodec* stream_codec); | 93 webrtc::VideoCodec* stream_codec); |
| 104 | 94 |
| 105 bool Initialized() const; | 95 bool Initialized() const; |
| 106 | 96 |
| 107 void DestroyStoredEncoders(); | 97 void DestroyStoredEncoders(); |
| 108 | 98 |
| 109 volatile int inited_; // Accessed atomically. | 99 volatile int inited_; // Accessed atomically. |
| 110 const std::unique_ptr<VideoEncoderFactory> factory_; | 100 cricket::WebRtcVideoEncoderFactory* const factory_; |
| 111 VideoCodec codec_; | 101 VideoCodec codec_; |
| 112 std::vector<StreamInfo> streaminfos_; | 102 std::vector<StreamInfo> streaminfos_; |
| 113 EncodedImageCallback* encoded_complete_callback_; | 103 EncodedImageCallback* encoded_complete_callback_; |
| 114 std::string implementation_name_; | 104 std::string implementation_name_; |
| 115 | 105 |
| 116 // Used for checking the single-threaded access of the encoder interface. | 106 // Used for checking the single-threaded access of the encoder interface. |
| 117 rtc::SequencedTaskChecker encoder_queue_; | 107 rtc::SequencedTaskChecker encoder_queue_; |
| 118 | 108 |
| 119 // Store encoders in between calls to Release and InitEncode, so they don't | 109 // Store encoders in between calls to Release and InitEncode, so they don't |
| 120 // have to be recreated. Remaining encoders are destroyed by the destructor. | 110 // have to be recreated. Remaining encoders are destroyed by the destructor. |
| 121 std::stack<VideoEncoder*> stored_encoders_; | 111 std::stack<VideoEncoder*> stored_encoders_; |
| 122 }; | 112 }; |
| 123 | 113 |
| 124 } // namespace webrtc | 114 } // namespace webrtc |
| 125 | 115 |
| 126 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_ENCODER_ADAPTER_H_ | 116 #endif // WEBRTC_MEDIA_ENGINE_SIMULCAST_ENCODER_ADAPTER_H_ |
| OLD | NEW |