| 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 MEDIA_BASE_ANDROID_MEDIA_DECODER_JOB_H_ | 5 #ifndef MEDIA_BASE_ANDROID_MEDIA_DECODER_JOB_H_ |
| 6 #define MEDIA_BASE_ANDROID_MEDIA_DECODER_JOB_H_ | 6 #define MEDIA_BASE_ANDROID_MEDIA_DECODER_JOB_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "media/base/android/demuxer_stream_player_params.h" | 11 #include "media/base/android/demuxer_stream_player_params.h" |
| 12 #include "media/base/android/media_codec_bridge.h" | 12 #include "media/base/android/media_codec_bridge.h" |
| 13 #include "ui/gl/android/scoped_java_surface.h" | 13 #include "ui/gl/android/scoped_java_surface.h" |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 class SingleThreadTaskRunner; | 16 class SingleThreadTaskRunner; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace media { | 19 namespace media { |
| 20 | 20 |
| 21 class FrameStatistics; |
| 21 class MediaDrmBridge; | 22 class MediaDrmBridge; |
| 22 | 23 |
| 23 // Class for managing all the decoding tasks. Each decoding task will be posted | 24 // Class for managing all the decoding tasks. Each decoding task will be posted |
| 24 // onto the same thread. The thread will be stopped once Stop() is called. | 25 // onto the same thread. The thread will be stopped once Stop() is called. |
| 25 // Data is stored in 2 chunks. When new data arrives, it is always stored in | 26 // Data is stored in 2 chunks. When new data arrives, it is always stored in |
| 26 // an inactive chunk. And when the current active chunk becomes empty, a new | 27 // an inactive chunk. And when the current active chunk becomes empty, a new |
| 27 // data request will be sent to the renderer. | 28 // data request will be sent to the renderer. |
| 28 class MediaDecoderJob { | 29 class MediaDecoderJob { |
| 29 public: | 30 public: |
| 30 // Return value when Decode() is called. | 31 // Return value when Decode() is called. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 111 |
| 111 protected: | 112 protected: |
| 112 // Creates a new MediaDecoderJob instance. | 113 // Creates a new MediaDecoderJob instance. |
| 113 // |decoder_task_runner| - Thread on which the decoder task will run. | 114 // |decoder_task_runner| - Thread on which the decoder task will run. |
| 114 // |request_data_cb| - Callback to request more data for the decoder. | 115 // |request_data_cb| - Callback to request more data for the decoder. |
| 115 // |config_changed_cb| - Callback to inform the caller that | 116 // |config_changed_cb| - Callback to inform the caller that |
| 116 // demuxer config has changed. | 117 // demuxer config has changed. |
| 117 MediaDecoderJob( | 118 MediaDecoderJob( |
| 118 const scoped_refptr<base::SingleThreadTaskRunner>& decoder_task_runner, | 119 const scoped_refptr<base::SingleThreadTaskRunner>& decoder_task_runner, |
| 119 const base::Closure& request_data_cb, | 120 const base::Closure& request_data_cb, |
| 120 const base::Closure& config_changed_cb); | 121 const base::Closure& config_changed_cb, |
| 122 FrameStatistics* frame_statistics); |
| 121 | 123 |
| 122 // Release the output buffer at index |output_buffer_index| and render it if | 124 // Release the output buffer at index |output_buffer_index| and render it if |
| 123 // |render_output| is true. Upon completion, |callback| will be called. | 125 // |render_output| is true. Upon completion, |callback| will be called. |
| 124 virtual void ReleaseOutputBuffer( | 126 virtual void ReleaseOutputBuffer( |
| 125 int output_buffer_index, | 127 int output_buffer_index, |
| 126 size_t offset, | 128 size_t offset, |
| 127 size_t size, | 129 size_t size, |
| 128 bool render_output, | 130 bool render_output, |
| 129 base::TimeDelta current_presentation_timestamp, | 131 base::TimeDelta current_presentation_timestamp, |
| 130 const ReleaseOutputCompletionCallback& callback) = 0; | 132 const ReleaseOutputCompletionCallback& callback) = 0; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 147 MediaDrmBridge* drm_bridge() { return drm_bridge_; } | 149 MediaDrmBridge* drm_bridge() { return drm_bridge_; } |
| 148 | 150 |
| 149 void set_is_content_encrypted(bool is_content_encrypted) { | 151 void set_is_content_encrypted(bool is_content_encrypted) { |
| 150 is_content_encrypted_ = is_content_encrypted; | 152 is_content_encrypted_ = is_content_encrypted; |
| 151 } | 153 } |
| 152 | 154 |
| 153 bool need_to_reconfig_decoder_job_; | 155 bool need_to_reconfig_decoder_job_; |
| 154 | 156 |
| 155 scoped_ptr<MediaCodecBridge> media_codec_bridge_; | 157 scoped_ptr<MediaCodecBridge> media_codec_bridge_; |
| 156 | 158 |
| 159 FrameStatistics* frame_statistics_; |
| 160 |
| 157 private: | 161 private: |
| 158 friend class MediaSourcePlayerTest; | 162 friend class MediaSourcePlayerTest; |
| 159 | 163 |
| 160 // Causes this instance to be deleted on the thread it is bound to. | 164 // Causes this instance to be deleted on the thread it is bound to. |
| 161 void Release(); | 165 void Release(); |
| 162 | 166 |
| 163 // Queues an access unit into |media_codec_bridge_|'s input buffer. | 167 // Queues an access unit into |media_codec_bridge_|'s input buffer. |
| 164 MediaCodecStatus QueueInputBuffer(const AccessUnit& unit); | 168 MediaCodecStatus QueueInputBuffer(const AccessUnit& unit); |
| 165 | 169 |
| 166 // Returns true if this object has data to decode. | 170 // Returns true if this object has data to decode. |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 // This access unit is passed to the decoder during config changes to drain | 357 // This access unit is passed to the decoder during config changes to drain |
| 354 // the decoder. | 358 // the decoder. |
| 355 AccessUnit eos_unit_; | 359 AccessUnit eos_unit_; |
| 356 | 360 |
| 357 DISALLOW_IMPLICIT_CONSTRUCTORS(MediaDecoderJob); | 361 DISALLOW_IMPLICIT_CONSTRUCTORS(MediaDecoderJob); |
| 358 }; | 362 }; |
| 359 | 363 |
| 360 } // namespace media | 364 } // namespace media |
| 361 | 365 |
| 362 #endif // MEDIA_BASE_ANDROID_MEDIA_DECODER_JOB_H_ | 366 #endif // MEDIA_BASE_ANDROID_MEDIA_DECODER_JOB_H_ |
| OLD | NEW |