OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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_VIDEO_VIE_ENCODER_H_ | 11 #ifndef WEBRTC_VIDEO_VIE_ENCODER_H_ |
12 #define WEBRTC_VIDEO_VIE_ENCODER_H_ | 12 #define WEBRTC_VIDEO_VIE_ENCODER_H_ |
13 | 13 |
14 #include <memory> | 14 #include <memory> |
| 15 #include <string> |
15 #include <vector> | 16 #include <vector> |
16 | 17 |
17 #include "webrtc/base/criticalsection.h" | 18 #include "webrtc/base/criticalsection.h" |
18 #include "webrtc/base/scoped_ref_ptr.h" | 19 #include "webrtc/base/scoped_ref_ptr.h" |
19 #include "webrtc/base/thread_annotations.h" | 20 #include "webrtc/base/thread_annotations.h" |
20 #include "webrtc/common_types.h" | 21 #include "webrtc/common_types.h" |
21 #include "webrtc/video_encoder.h" | 22 #include "webrtc/video_encoder.h" |
22 #include "webrtc/media/base/videosinkinterface.h" | 23 #include "webrtc/media/base/videosinkinterface.h" |
23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 24 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
24 #include "webrtc/modules/video_coding/include/video_coding_defines.h" | 25 #include "webrtc/modules/video_coding/include/video_coding_defines.h" |
(...skipping 20 matching lines...) Expand all Loading... |
45 // Usage: | 46 // Usage: |
46 // 1. Instantiate | 47 // 1. Instantiate |
47 // 2. Call Init | 48 // 2. Call Init |
48 // 3. Call RegisterExternalEncoder if available. | 49 // 3. Call RegisterExternalEncoder if available. |
49 // 4. Call SetEncoder with the codec settings and the object that shall receive | 50 // 4. Call SetEncoder with the codec settings and the object that shall receive |
50 // the encoded bit stream. | 51 // the encoded bit stream. |
51 // 5. Call Start. | 52 // 5. Call Start. |
52 // 6. For each available raw video frame call EncodeVideoFrame. | 53 // 6. For each available raw video frame call EncodeVideoFrame. |
53 class ViEEncoder : public VideoEncoderRateObserver, | 54 class ViEEncoder : public VideoEncoderRateObserver, |
54 public EncodedImageCallback, | 55 public EncodedImageCallback, |
55 public VCMPacketizationCallback, | |
56 public VCMSendStatisticsCallback { | 56 public VCMSendStatisticsCallback { |
57 public: | 57 public: |
58 friend class ViEBitrateObserver; | 58 friend class ViEBitrateObserver; |
59 | 59 |
60 ViEEncoder(uint32_t number_of_cores, | 60 ViEEncoder(uint32_t number_of_cores, |
61 const std::vector<uint32_t>& ssrcs, | 61 const std::vector<uint32_t>& ssrcs, |
62 ProcessThread* module_process_thread, | 62 ProcessThread* module_process_thread, |
63 SendStatisticsProxy* stats_proxy, | 63 SendStatisticsProxy* stats_proxy, |
64 // TODO(nisse): Used only for tests, delete? | 64 // TODO(nisse): Used only for tests, delete? |
65 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback, | 65 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback, |
66 OveruseFrameDetector* overuse_detector, | 66 OveruseFrameDetector* overuse_detector, |
67 PacedSender* pacer); | 67 PacedSender* pacer); |
68 ~ViEEncoder(); | 68 ~ViEEncoder(); |
69 | 69 |
70 bool Init(); | |
71 | |
72 vcm::VideoSender* video_sender(); | 70 vcm::VideoSender* video_sender(); |
73 | 71 |
74 void SetNetworkTransmissionState(bool is_transmitting); | 72 void SetNetworkTransmissionState(bool is_transmitting); |
75 | 73 |
76 // Returns the id of the owning channel. | 74 // Returns the id of the owning channel. |
77 int Owner() const; | 75 int Owner() const; |
78 | 76 |
79 void Start(); | 77 void Start(); |
80 // Drops incoming packets before they get to the encoder. | 78 // Drops incoming packets before they get to the encoder. |
81 void Pause(); | 79 void Pause(); |
(...skipping 13 matching lines...) Expand all Loading... |
95 | 93 |
96 uint32_t LastObservedBitrateBps() const; | 94 uint32_t LastObservedBitrateBps() const; |
97 // Loss protection. Must be called before SetEncoder() to have max packet size | 95 // Loss protection. Must be called before SetEncoder() to have max packet size |
98 // updated according to protection. | 96 // updated according to protection. |
99 // TODO(pbos): Set protection method on construction. | 97 // TODO(pbos): Set protection method on construction. |
100 void SetProtectionMethod(bool nack, bool fec); | 98 void SetProtectionMethod(bool nack, bool fec); |
101 | 99 |
102 // Implements VideoEncoderRateObserver. | 100 // Implements VideoEncoderRateObserver. |
103 void OnSetRates(uint32_t bitrate_bps, int framerate) override; | 101 void OnSetRates(uint32_t bitrate_bps, int framerate) override; |
104 | 102 |
105 // Implements VCMPacketizationCallback. | |
106 void OnEncoderImplementationName(const char* implementation_name) override; | |
107 | |
108 // Implements EncodedImageCallback. | 103 // Implements EncodedImageCallback. |
109 int32_t Encoded(const EncodedImage& encoded_image, | 104 int32_t Encoded(const EncodedImage& encoded_image, |
110 const CodecSpecificInfo* codec_specific_info, | 105 const CodecSpecificInfo* codec_specific_info, |
111 const RTPFragmentationHeader* fragmentation) override; | 106 const RTPFragmentationHeader* fragmentation) override; |
112 | 107 |
113 // Implements VideoSendStatisticsCallback. | 108 // Implements VideoSendStatisticsCallback. |
114 int32_t SendStatistics(const uint32_t bit_rate, | 109 void SendStatistics(uint32_t bit_rate, |
115 const uint32_t frame_rate) override; | 110 uint32_t frame_rate, |
| 111 const std::string& encoder_name) override; |
116 | 112 |
117 // virtual to test EncoderStateFeedback with mocks. | 113 // virtual to test EncoderStateFeedback with mocks. |
118 virtual void OnReceivedIntraFrameRequest(uint32_t ssrc); | 114 virtual void OnReceivedIntraFrameRequest(uint32_t ssrc); |
119 virtual void OnReceivedSLI(uint32_t ssrc, uint8_t picture_id); | 115 virtual void OnReceivedSLI(uint32_t ssrc, uint8_t picture_id); |
120 virtual void OnReceivedRPSI(uint32_t ssrc, uint64_t picture_id); | 116 virtual void OnReceivedRPSI(uint32_t ssrc, uint64_t picture_id); |
121 | 117 |
122 int GetPaddingNeededBps() const; | 118 int GetPaddingNeededBps() const; |
123 | 119 |
124 void OnBitrateUpdated(uint32_t bitrate_bps, | 120 void OnBitrateUpdated(uint32_t bitrate_bps, |
125 uint8_t fraction_lost, | 121 uint8_t fraction_lost, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 uint64_t picture_id_rpsi_ GUARDED_BY(data_cs_); | 166 uint64_t picture_id_rpsi_ GUARDED_BY(data_cs_); |
171 | 167 |
172 bool video_suspended_ GUARDED_BY(data_cs_); | 168 bool video_suspended_ GUARDED_BY(data_cs_); |
173 | 169 |
174 std::unique_ptr<IvfFileWriter> file_writers_[kMaxLayers] GUARDED_BY(data_cs_); | 170 std::unique_ptr<IvfFileWriter> file_writers_[kMaxLayers] GUARDED_BY(data_cs_); |
175 }; | 171 }; |
176 | 172 |
177 } // namespace webrtc | 173 } // namespace webrtc |
178 | 174 |
179 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ | 175 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ |
OLD | NEW |