Upstream version 8.37.180.0
[platform/framework/web/crosswalk.git] / src / media / base / android / video_decoder_job.h
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.
4
5 #ifndef MEDIA_BASE_ANDROID_VIDEO_DECODER_JOB_H_
6 #define MEDIA_BASE_ANDROID_VIDEO_DECODER_JOB_H_
7
8 #include <jni.h>
9
10 #include "media/base/android/media_decoder_job.h"
11
12 namespace media {
13
14 class VideoCodecBridge;
15
16 // Class for managing video decoding jobs.
17 class VideoDecoderJob : public MediaDecoderJob {
18  public:
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.
25   VideoDecoderJob(
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();
31
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);
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_; }
47
48  private:
49   // MediaDecoderJob implementation.
50   virtual void ReleaseOutputBuffer(
51       int output_buffer_index,
52       size_t size,
53       bool render_output,
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;
65
66   // Returns true if a protected surface is required for video playback.
67   bool IsProtectedSurfaceRequired();
68
69   // Video configs from the demuxer.
70   VideoCodec video_codec_;
71   int width_;
72   int height_;
73
74   // The surface object currently owned by the player.
75   gfx::ScopedJavaSurface surface_;
76
77   // Callbacks to inform the caller about decoder resources change.
78   base::Closure request_resources_cb_;
79   base::Closure release_resources_cb_;
80
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
83   // I-frame.
84   bool next_video_data_is_iframe_;
85
86   DISALLOW_COPY_AND_ASSIGN(VideoDecoderJob);
87 };
88
89 }  // namespace media
90
91 #endif  // MEDIA_BASE_ANDROID_VIDEO_DECODER_JOB_H_