Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_ENCODE_ACCELERATOR_H_ | 5 #ifndef CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_ENCODE_ACCELERATOR_H_ |
| 6 #define CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_ENCODE_ACCELERATOR_H_ | 6 #define CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_ENCODE_ACCELERATOR_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | |
| 9 | |
| 8 #include <list> | 10 #include <list> |
| 9 #include <queue> | 11 #include <queue> |
| 10 #include <vector> | 12 #include <vector> |
| 11 | 13 |
| 12 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 13 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
| 14 #include "base/timer/timer.h" | 16 #include "base/timer/timer.h" |
| 15 #include "base/tuple.h" | 17 #include "base/tuple.h" |
| 16 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
| 17 #include "media/base/android/sdk_media_codec_bridge.h" | 19 #include "media/base/android/sdk_media_codec_bridge.h" |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 33 public: | 35 public: |
| 34 AndroidVideoEncodeAccelerator(); | 36 AndroidVideoEncodeAccelerator(); |
| 35 ~AndroidVideoEncodeAccelerator() override; | 37 ~AndroidVideoEncodeAccelerator() override; |
| 36 | 38 |
| 37 // media::VideoEncodeAccelerator implementation. | 39 // media::VideoEncodeAccelerator implementation. |
| 38 media::VideoEncodeAccelerator::SupportedProfiles GetSupportedProfiles() | 40 media::VideoEncodeAccelerator::SupportedProfiles GetSupportedProfiles() |
| 39 override; | 41 override; |
| 40 bool Initialize(media::VideoPixelFormat format, | 42 bool Initialize(media::VideoPixelFormat format, |
| 41 const gfx::Size& input_visible_size, | 43 const gfx::Size& input_visible_size, |
| 42 media::VideoCodecProfile output_profile, | 44 media::VideoCodecProfile output_profile, |
| 43 uint32 initial_bitrate, | 45 uint32_t initial_bitrate, |
| 44 Client* client) override; | 46 Client* client) override; |
| 45 void Encode(const scoped_refptr<media::VideoFrame>& frame, | 47 void Encode(const scoped_refptr<media::VideoFrame>& frame, |
| 46 bool force_keyframe) override; | 48 bool force_keyframe) override; |
| 47 void UseOutputBitstreamBuffer(const media::BitstreamBuffer& buffer) override; | 49 void UseOutputBitstreamBuffer(const media::BitstreamBuffer& buffer) override; |
| 48 void RequestEncodingParametersChange(uint32 bitrate, | 50 void RequestEncodingParametersChange(uint32_t bitrate, |
| 49 uint32 framerate) override; | 51 uint32_t framerate) override; |
| 50 void Destroy() override; | 52 void Destroy() override; |
| 51 | 53 |
| 52 private: | 54 private: |
| 53 enum { | 55 enum { |
| 54 // Arbitrary choice. | 56 // Arbitrary choice. |
| 55 INITIAL_FRAMERATE = 30, | 57 INITIAL_FRAMERATE = 30, |
| 56 // Until there are non-realtime users, no need for unrequested I-frames. | 58 // Until there are non-realtime users, no need for unrequested I-frames. |
| 57 IFRAME_INTERVAL = kint32max, | 59 IFRAME_INTERVAL = INT32_MAX, |
|
sky
2015/12/07 16:43:46
How come you use INT32_MAX here?
Avi (use Gerrit)
2015/12/07 17:37:32
This is an enum, so I need a real constant here, n
| |
| 58 }; | 60 }; |
| 59 | 61 |
| 60 // Impedance-mismatch fixers: MediaCodec is a poll-based API but VEA is a | 62 // Impedance-mismatch fixers: MediaCodec is a poll-based API but VEA is a |
| 61 // push-based API; these methods turn the crank to make the two work together. | 63 // push-based API; these methods turn the crank to make the two work together. |
| 62 void DoIOTask(); | 64 void DoIOTask(); |
| 63 void QueueInput(); | 65 void QueueInput(); |
| 64 void DequeueOutput(); | 66 void DequeueOutput(); |
| 65 | 67 |
| 66 // Returns true if we don't need more or bigger output buffers. | 68 // Returns true if we don't need more or bigger output buffers. |
| 67 bool DoOutputBuffersSuffice(); | 69 bool DoOutputBuffersSuffice(); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 86 // available. Each element is a tuple of <Frame, key_frame, enqueue_time>. | 88 // available. Each element is a tuple of <Frame, key_frame, enqueue_time>. |
| 87 typedef std::queue< | 89 typedef std::queue< |
| 88 base::Tuple<scoped_refptr<media::VideoFrame>, bool, base::Time>> | 90 base::Tuple<scoped_refptr<media::VideoFrame>, bool, base::Time>> |
| 89 PendingFrames; | 91 PendingFrames; |
| 90 PendingFrames pending_frames_; | 92 PendingFrames pending_frames_; |
| 91 | 93 |
| 92 // Repeating timer responsible for draining pending IO to the codec. | 94 // Repeating timer responsible for draining pending IO to the codec. |
| 93 base::RepeatingTimer io_timer_; | 95 base::RepeatingTimer io_timer_; |
| 94 | 96 |
| 95 // The difference between number of buffers queued & dequeued at the codec. | 97 // The difference between number of buffers queued & dequeued at the codec. |
| 96 int32 num_buffers_at_codec_; | 98 int32_t num_buffers_at_codec_; |
| 97 | 99 |
| 98 // A monotonically-growing value, used as a fake timestamp just to keep things | 100 // A monotonically-growing value, used as a fake timestamp just to keep things |
| 99 // appearing to move forward. | 101 // appearing to move forward. |
| 100 base::TimeDelta fake_input_timestamp_; | 102 base::TimeDelta fake_input_timestamp_; |
| 101 | 103 |
| 102 // Number of requested output buffers and their capacity. | 104 // Number of requested output buffers and their capacity. |
| 103 int num_output_buffers_; // -1 until RequireBitstreamBuffers. | 105 int num_output_buffers_; // -1 until RequireBitstreamBuffers. |
| 104 size_t output_buffers_capacity_; // 0 until RequireBitstreamBuffers. | 106 size_t output_buffers_capacity_; // 0 until RequireBitstreamBuffers. |
| 105 | 107 |
| 106 uint32 last_set_bitrate_; // In bps. | 108 uint32_t last_set_bitrate_; // In bps. |
| 107 | 109 |
| 108 DISALLOW_COPY_AND_ASSIGN(AndroidVideoEncodeAccelerator); | 110 DISALLOW_COPY_AND_ASSIGN(AndroidVideoEncodeAccelerator); |
| 109 }; | 111 }; |
| 110 | 112 |
| 111 } // namespace content | 113 } // namespace content |
| 112 | 114 |
| 113 #endif // CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_ENCODE_ACCELERATOR_H_ | 115 #endif // CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_ENCODE_ACCELERATOR_H_ |
| OLD | NEW |