| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_CAST_SENDER_CODECS_VP8_VP8_ENCODER_H_ | 5 #ifndef MEDIA_CAST_SENDER_CODECS_VP8_VP8_ENCODER_H_ |
| 6 #define MEDIA_CAST_SENDER_CODECS_VP8_VP8_ENCODER_H_ | 6 #define MEDIA_CAST_SENDER_CODECS_VP8_VP8_ENCODER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/threading/thread_checker.h" | 9 #include "base/threading/thread_checker.h" |
| 11 #include "media/cast/cast_config.h" | 10 #include "media/cast/cast_config.h" |
| 12 #include "media/cast/sender/software_video_encoder.h" | 11 #include "media/cast/sender/software_video_encoder.h" |
| 13 #include "third_party/libvpx_new/source/libvpx/vpx/vpx_encoder.h" | 12 #include "third_party/libvpx_new/source/libvpx/vpx/vpx_encoder.h" |
| 14 #include "ui/gfx/geometry/size.h" | 13 #include "ui/gfx/geometry/size.h" |
| 15 | 14 |
| 16 namespace media { | 15 namespace media { |
| 17 class VideoFrame; | 16 class VideoFrame; |
| 18 } | 17 } |
| 19 | 18 |
| 20 namespace media { | 19 namespace media { |
| 21 namespace cast { | 20 namespace cast { |
| 22 | 21 |
| 23 class Vp8Encoder : public SoftwareVideoEncoder { | 22 class Vp8Encoder : public SoftwareVideoEncoder { |
| 24 public: | 23 public: |
| 25 explicit Vp8Encoder(const VideoSenderConfig& video_config); | 24 explicit Vp8Encoder(const VideoSenderConfig& video_config); |
| 26 | 25 |
| 27 ~Vp8Encoder() final; | 26 ~Vp8Encoder() final; |
| 28 | 27 |
| 29 // SoftwareVideoEncoder implementations. | 28 // SoftwareVideoEncoder implementations. |
| 30 void Initialize() final; | 29 void Initialize() final; |
| 31 void Encode(const scoped_refptr<media::VideoFrame>& video_frame, | 30 void Encode(const scoped_refptr<media::VideoFrame>& video_frame, |
| 32 const base::TimeTicks& reference_time, | 31 const base::TimeTicks& reference_time, |
| 33 SenderEncodedFrame* encoded_frame) final; | 32 SenderEncodedFrame* encoded_frame) final; |
| 34 void UpdateRates(uint32 new_bitrate) final; | 33 void UpdateRates(uint32_t new_bitrate) final; |
| 35 void GenerateKeyFrame() final; | 34 void GenerateKeyFrame() final; |
| 36 | 35 |
| 37 private: | 36 private: |
| 38 bool is_initialized() const { | 37 bool is_initialized() const { |
| 39 // ConfigureForNewFrameSize() sets the timebase denominator value to | 38 // ConfigureForNewFrameSize() sets the timebase denominator value to |
| 40 // non-zero if the encoder is successfully initialized, and it is zero | 39 // non-zero if the encoder is successfully initialized, and it is zero |
| 41 // otherwise. | 40 // otherwise. |
| 42 return config_.g_timebase.den != 0; | 41 return config_.g_timebase.den != 0; |
| 43 } | 42 } |
| 44 | 43 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 59 | 58 |
| 60 // Saves the current bitrate setting, for when the |encoder_| is reconfigured | 59 // Saves the current bitrate setting, for when the |encoder_| is reconfigured |
| 61 // for different frame sizes. | 60 // for different frame sizes. |
| 62 int bitrate_kbit_; | 61 int bitrate_kbit_; |
| 63 | 62 |
| 64 // The |VideoFrame::timestamp()| of the last encoded frame. This is used to | 63 // The |VideoFrame::timestamp()| of the last encoded frame. This is used to |
| 65 // predict the duration of the next frame. | 64 // predict the duration of the next frame. |
| 66 base::TimeDelta last_frame_timestamp_; | 65 base::TimeDelta last_frame_timestamp_; |
| 67 | 66 |
| 68 // The last encoded frame's ID. | 67 // The last encoded frame's ID. |
| 69 uint32 last_encoded_frame_id_; | 68 uint32_t last_encoded_frame_id_; |
| 70 | 69 |
| 71 // This is bound to the thread where Initialize() is called. | 70 // This is bound to the thread where Initialize() is called. |
| 72 base::ThreadChecker thread_checker_; | 71 base::ThreadChecker thread_checker_; |
| 73 | 72 |
| 74 // Set to true once a frame with zero-length encoded data has been | 73 // Set to true once a frame with zero-length encoded data has been |
| 75 // encountered. | 74 // encountered. |
| 76 // TODO(miu): Remove after discovering cause. http://crbug.com/519022 | 75 // TODO(miu): Remove after discovering cause. http://crbug.com/519022 |
| 77 bool has_seen_zero_length_encoded_frame_; | 76 bool has_seen_zero_length_encoded_frame_; |
| 78 | 77 |
| 79 DISALLOW_COPY_AND_ASSIGN(Vp8Encoder); | 78 DISALLOW_COPY_AND_ASSIGN(Vp8Encoder); |
| 80 }; | 79 }; |
| 81 | 80 |
| 82 } // namespace cast | 81 } // namespace cast |
| 83 } // namespace media | 82 } // namespace media |
| 84 | 83 |
| 85 #endif // MEDIA_CAST_SENDER_CODECS_VP8_VP8_ENCODER_H_ | 84 #endif // MEDIA_CAST_SENDER_CODECS_VP8_VP8_ENCODER_H_ |
| OLD | NEW |