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_VIDEO_DECODER_JOB_H_ | 5 #ifndef MEDIA_BASE_ANDROID_VIDEO_DECODER_JOB_H_ |
6 #define MEDIA_BASE_ANDROID_VIDEO_DECODER_JOB_H_ | 6 #define MEDIA_BASE_ANDROID_VIDEO_DECODER_JOB_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 | 9 |
10 #include "media/base/android/media_decoder_job.h" | 10 #include "media/base/android/media_decoder_job.h" |
11 | 11 |
12 namespace media { | 12 namespace media { |
13 | 13 |
14 class VideoCodecBridge; | 14 class VideoCodecBridge; |
15 | 15 |
16 // Class for managing video decoding jobs. | 16 // Class for managing video decoding jobs. |
17 class VideoDecoderJob : public MediaDecoderJob { | 17 class VideoDecoderJob : public MediaDecoderJob { |
18 public: | 18 public: |
19 virtual ~VideoDecoderJob(); | |
20 | |
21 // Create a new VideoDecoderJob instance. | 19 // Create a new VideoDecoderJob instance. |
22 // |video_codec| - The video format the object needs to decode. | |
23 // |is_secure| - Whether secure decoding is required. | |
24 // |size| - The natural size of the output frames. | |
25 // |surface| - The surface to render the frames to. | |
26 // |media_crypto| - Handle to a Java object responsible for decrypting the | |
27 // video data. | |
28 // |request_data_cb| - Callback used to request more data for the decoder. | 20 // |request_data_cb| - Callback used to request more data for the decoder. |
29 // |request_resources_cb| - Callback used to request resources. | 21 // |request_resources_cb| - Callback used to request resources. |
30 // |release_resources_cb| - Callback used to release resources. | 22 // |release_resources_cb| - Callback used to release resources. |
31 static VideoDecoderJob* Create(const VideoCodec video_codec, | 23 // |on_demuxer_config_changed_cb| - Callback used to inform the caller that |
32 bool is_secure, | 24 // demuxer config has changed. |
33 const gfx::Size& size, | 25 VideoDecoderJob( |
34 jobject surface, | 26 const base::Closure& request_data_cb, |
35 jobject media_crypto, | 27 const base::Closure& request_resources_cb, |
36 const base::Closure& request_data_cb, | 28 const base::Closure& release_resources_cb, |
37 const base::Closure& request_resources_cb, | 29 const base::Closure& on_demuxer_config_changed_cb); |
38 const base::Closure& release_resources_cb); | 30 ~VideoDecoderJob(); |
31 | |
32 // Passes an java surface object to the codec. Returns true if the surface | |
wolenetz
2014/05/27 22:21:13
nit: s/an//
qinmin
2014/05/28 00:28:16
Done.
| |
33 // can be used by the decoder, or false otherwise. | |
34 bool SetVideoSurface(gfx::ScopedJavaSurface surface); | |
35 | |
36 // MediaDecoderJob implementation. | |
37 virtual bool HasStream() const OVERRIDE; | |
38 virtual void Flush() OVERRIDE; | |
39 virtual void ReleaseDecoderResources() OVERRIDE; | |
40 | |
41 bool next_video_data_is_iframe() { | |
42 return next_video_data_is_iframe_; | |
43 } | |
44 | |
45 int width() const { return width_; } | |
46 int height() const { return height_; } | |
39 | 47 |
40 private: | 48 private: |
41 VideoDecoderJob(scoped_ptr<VideoCodecBridge> video_codec_bridge, | |
42 const base::Closure& request_data_cb, | |
43 const base::Closure& request_resources_cb, | |
44 const base::Closure& release_resources_cb); | |
45 | |
46 // MediaDecoderJob implementation. | 49 // MediaDecoderJob implementation. |
47 virtual void ReleaseOutputBuffer( | 50 virtual void ReleaseOutputBuffer( |
48 int output_buffer_index, | 51 int output_buffer_index, |
49 size_t size, | 52 size_t size, |
50 bool render_output, | 53 bool render_output, |
51 base::TimeDelta current_presentation_timestamp, | 54 base::TimeDelta current_presentation_timestamp, |
52 const ReleaseOutputCompletionCallback& callback) OVERRIDE; | 55 const ReleaseOutputCompletionCallback& callback) OVERRIDE; |
56 virtual bool ComputeTimeToRender() const OVERRIDE; | |
57 virtual void UpdateDemuxerConfigs(const DemuxerConfigs& configs) OVERRIDE; | |
58 virtual bool IsDemuxerConfigChanged( | |
59 const DemuxerConfigs& configs) const OVERRIDE; | |
60 virtual bool CreateMediaCodecBridgeInternal() OVERRIDE; | |
61 virtual void CurrentDataConsumed(bool is_config_change) OVERRIDE; | |
62 virtual void OnMediaCodecBridgeReleased() OVERRIDE; | |
53 | 63 |
54 virtual bool ComputeTimeToRender() const OVERRIDE; | 64 // Returns true if a protected surface is required for video playback. |
65 bool IsProtectedSurfaceRequired(); | |
55 | 66 |
56 scoped_ptr<VideoCodecBridge> video_codec_bridge_; | 67 // Video configs from the demuxer. |
68 VideoCodec video_codec_; | |
69 int width_; | |
70 int height_; | |
57 | 71 |
72 // The surface object currently owned by the player. | |
73 gfx::ScopedJavaSurface surface_; | |
74 | |
75 // Callbacks to inform the caller about decoder resources change. | |
76 base::Closure request_resources_cb_; | |
58 base::Closure release_resources_cb_; | 77 base::Closure release_resources_cb_; |
78 | |
79 // Track whether the next access unit is an I-frame. The first access | |
80 // unit after Flush() and CurrentDataConsumed(true) is guaranteed to be an | |
81 // I-frame. | |
82 bool next_video_data_is_iframe_; | |
83 | |
84 DISALLOW_COPY_AND_ASSIGN(VideoDecoderJob); | |
59 }; | 85 }; |
60 | 86 |
61 } // namespace media | 87 } // namespace media |
62 | 88 |
63 #endif // MEDIA_BASE_ANDROID_VIDEO_DECODER_JOB_H_ | 89 #endif // MEDIA_BASE_ANDROID_VIDEO_DECODER_JOB_H_ |
OLD | NEW |