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 // |release_resources_cb| - Callback used to release resources.
23 // |on_demuxer_config_changed_cb| - Callback used to inform the caller that
24 // demuxer config has changed.
26 const base::Closure& request_data_cb,
27 const base::Closure& request_resources_cb,
28 const base::Closure& release_resources_cb,
29 const base::Closure& on_demuxer_config_changed_cb);
30 virtual ~VideoDecoderJob();
32 // Passes a java surface object to the codec. Returns true if the surface
33 // can be used by the decoder, or false otherwise.
34 bool SetVideoSurface(gfx::ScopedJavaSurface surface);
36 // MediaDecoderJob implementation.
37 virtual bool HasStream() const OVERRIDE;
38 virtual void Flush() OVERRIDE;
39 virtual void ReleaseDecoderResources() OVERRIDE;
41 bool next_video_data_is_iframe() {
42 return next_video_data_is_iframe_;
45 int width() const { return width_; }
46 int height() const { return height_; }
49 // MediaDecoderJob implementation.
50 virtual void ReleaseOutputBuffer(
51 int output_buffer_index,
54 base::TimeDelta current_presentation_timestamp,
55 const ReleaseOutputCompletionCallback& callback) OVERRIDE;
56 virtual bool ComputeTimeToRender() const OVERRIDE;
57 virtual void UpdateDemuxerConfigs(const DemuxerConfigs& configs) OVERRIDE;
58 virtual bool IsCodecReconfigureNeeded(
59 const DemuxerConfigs& configs) const OVERRIDE;
60 virtual bool AreDemuxerConfigsChanged(
61 const DemuxerConfigs& configs) const OVERRIDE;
62 virtual bool CreateMediaCodecBridgeInternal() OVERRIDE;
63 virtual void CurrentDataConsumed(bool is_config_change) OVERRIDE;
64 virtual void OnMediaCodecBridgeReleased() OVERRIDE;
66 // Returns true if a protected surface is required for video playback.
67 bool IsProtectedSurfaceRequired();
69 // Video configs from the demuxer.
70 VideoCodec video_codec_;
74 // The surface object currently owned by the player.
75 gfx::ScopedJavaSurface surface_;
77 // Callbacks to inform the caller about decoder resources change.
78 base::Closure request_resources_cb_;
79 base::Closure release_resources_cb_;
81 // Track whether the next access unit is an I-frame. The first access
82 // unit after Flush() and CurrentDataConsumed(true) is guaranteed to be an
84 bool next_video_data_is_iframe_;
86 DISALLOW_COPY_AND_ASSIGN(VideoDecoderJob);
91 #endif // MEDIA_BASE_ANDROID_VIDEO_DECODER_JOB_H_