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;
39 bool next_video_data_is_iframe() {
40 return next_video_data_is_iframe_;
43 int width() const { return width_; }
44 int height() const { return height_; }
47 // MediaDecoderJob implementation.
48 virtual void ReleaseOutputBuffer(
49 int output_buffer_index,
52 base::TimeDelta current_presentation_timestamp,
53 const ReleaseOutputCompletionCallback& callback) OVERRIDE;
54 virtual bool ComputeTimeToRender() const OVERRIDE;
55 virtual void UpdateDemuxerConfigs(const DemuxerConfigs& configs) 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;
63 // Returns true if a protected surface is required for video playback.
64 bool IsProtectedSurfaceRequired();
66 // Video configs from the demuxer.
67 VideoCodec video_codec_;
71 // The surface object currently owned by the player.
72 gfx::ScopedJavaSurface surface_;
74 // Callbacks to inform the caller about decoder resources change.
75 base::Closure request_resources_cb_;
76 base::Closure release_resources_cb_;
78 // Track whether the next access unit is an I-frame. The first access
79 // unit after Flush() and CurrentDataConsumed(true) is guaranteed to be an
81 bool next_video_data_is_iframe_;
83 DISALLOW_COPY_AND_ASSIGN(VideoDecoderJob);
88 #endif // MEDIA_BASE_ANDROID_VIDEO_DECODER_JOB_H_