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
3 // found in the LICENSE file.
5 #ifndef MEDIA_BASE_ANDROID_VIDEO_DECODER_JOB_H_
6 #define MEDIA_BASE_ANDROID_VIDEO_DECODER_JOB_H_
10 #include "media/base/android/media_decoder_job.h"
14 class VideoCodecBridge
;
16 // Class for managing video decoding jobs.
17 class VideoDecoderJob
: public MediaDecoderJob
{
19 // Create a new VideoDecoderJob instance.
20 // |request_data_cb| - Callback used to request more data for the decoder.
21 // |request_resources_cb| - Callback used to request resources.
22 // |on_demuxer_config_changed_cb| - Callback used to inform the caller that
23 // demuxer config has changed.
25 const base::Closure
& request_data_cb
,
26 const base::Closure
& request_resources_cb
,
27 const base::Closure
& on_demuxer_config_changed_cb
);
28 virtual ~VideoDecoderJob();
30 // Passes a java surface object to the codec. Returns true if the surface
31 // can be used by the decoder, or false otherwise.
32 bool SetVideoSurface(gfx::ScopedJavaSurface surface
);
34 // MediaDecoderJob implementation.
35 virtual bool HasStream() const override
;
36 virtual void Flush() override
;
37 virtual void ReleaseDecoderResources() override
;
38 virtual void SetDemuxerConfigs(const DemuxerConfigs
& configs
) override
;
40 bool next_video_data_is_iframe() {
41 return next_video_data_is_iframe_
;
44 int output_width() const { return output_width_
; }
45 int output_height() const { return output_height_
; }
48 // MediaDecoderJob implementation.
49 virtual void ReleaseOutputBuffer(
50 int output_buffer_index
,
53 base::TimeDelta current_presentation_timestamp
,
54 const ReleaseOutputCompletionCallback
& callback
) override
;
55 virtual bool ComputeTimeToRender() const override
;
56 virtual bool IsCodecReconfigureNeeded(
57 const DemuxerConfigs
& configs
) const override
;
58 virtual bool AreDemuxerConfigsChanged(
59 const DemuxerConfigs
& configs
) const override
;
60 virtual bool CreateMediaCodecBridgeInternal() override
;
61 virtual void CurrentDataConsumed(bool is_config_change
) override
;
62 virtual bool UpdateOutputFormat() override
;
64 // Returns true if a protected surface is required for video playback.
65 bool IsProtectedSurfaceRequired();
67 // Video configs from the demuxer.
68 VideoCodec video_codec_
;
72 // Video output format.
76 // The surface object currently owned by the player.
77 gfx::ScopedJavaSurface surface_
;
79 // Callbacks to inform the caller about decoder resources change.
80 base::Closure request_resources_cb_
;
81 base::Closure release_resources_cb_
;
83 // Track whether the next access unit is an I-frame. The first access
84 // unit after Flush() and CurrentDataConsumed(true) is guaranteed to be an
86 bool next_video_data_is_iframe_
;
88 DISALLOW_COPY_AND_ASSIGN(VideoDecoderJob
);
93 #endif // MEDIA_BASE_ANDROID_VIDEO_DECODER_JOB_H_