Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: content/common/gpu/media/android_video_decode_accelerator.h

Issue 11973010: AndroidVDA by using Android's MediaCodec API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 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 CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_
6 #define CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_
7
8 #include <dlfcn.h>
9 #include <map>
10 #include <queue>
11 #include <set>
12 #include <string>
13 #include <utility>
14 #include <vector>
15
16 #include "base/compiler_specific.h"
17 #include "base/logging.h"
18 #include "base/message_loop.h"
19 #include "base/shared_memory.h"
20 #include "content/common/android/surface_texture_bridge.h"
21 #include "content/common/content_export.h"
22 #include "media/video/video_decode_accelerator.h"
23
24 namespace media {
25 class MediaCodecBridge;
26 }
27
28 namespace content {
29
30 class Gles2ExternalTextureCopier;
31
32 typedef std::map<int32, media::PictureBuffer> PictureMap;
33
34 // A VideoDecodeAccelerator implementation for Android.
35 // This class decodes the input encoded stream by using Android's MediaCodec
36 // class. http://developer.android.com/reference/android/media/MediaCodec.html
37 class CONTENT_EXPORT AndroidVideoDecodeAccelerator :
38 public media::VideoDecodeAccelerator {
39 public:
40 // Does not take ownership of |client| which must outlive |*this|.
41 AndroidVideoDecodeAccelerator(
42 media::VideoDecodeAccelerator::Client* client,
43 const base::Callback<bool(void)>& make_context_current);
44 virtual ~AndroidVideoDecodeAccelerator();
45
46 // media::VideoDecodeAccelerator implementation.
47 bool Initialize(media::VideoCodecProfile profile) OVERRIDE;
48 void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE;
49 virtual void AssignPictureBuffers(
50 const std::vector<media::PictureBuffer>& buffers) OVERRIDE;
51 void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE;
52 void Flush() OVERRIDE;
53 void Reset() OVERRIDE;
54 void Destroy() OVERRIDE;
55
56 private:
57 enum Codec {
58 UNKNOWN,
59 H264,
60 VP8
61 };
62
63 void SendCurrentSurfaceToClient();
64 void CopyCurrentFrameToPictureBuffer(
65 int32 picture_buffer_id, float transfrom_matrix[16]);
66
67 void DoDecode();
68 void ConfigureMediaCodec();
69 void QueueInput();
70 void DequeueOutput();
71
72 MessageLoop* message_loop_;
73
74 // To expose client callbacks from VideoDecodeAccelerator.
75 // NOTE: all calls to this object *MUST* be executed in message_loop_.
76 Client* client_;
77
78 base::Callback<bool(void)> make_context_current_;
79
80 // These members are only used during Initialization.
81 Codec codec_;
82
83 PictureMap picture_map_;
84 std::queue<int32> free_picture_ids_;
85 scoped_ptr<media::MediaCodecBridge> media_codec_;
86 scoped_refptr<SurfaceTextureBridge> surface_texture_;
87 uint32 surface_texture_id_;
88 bool picturebuffer_requested_;
89
90 typedef std::queue<media::BitstreamBuffer> BitstreamBufferList;
91 BitstreamBufferList pending_bitstream_buffers_;
92
93 int32 color_format_;
94 int32 width_;
95 int32 height_;
96 int32 current_bitstream_id_;
97
98 scoped_ptr<Gles2ExternalTextureCopier> texture_copier_;
99 };
100
101 } // namespace content
102
103 #endif // CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698