OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ | 5 #ifndef MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ |
6 #define MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ | 6 #define MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/weak_ptr.h" | |
12 #include "media/base/bitstream_buffer.h" | 11 #include "media/base/bitstream_buffer.h" |
13 #include "media/base/video_decoder_config.h" | 12 #include "media/base/video_decoder_config.h" |
14 #include "media/video/picture.h" | 13 #include "media/video/picture.h" |
15 #include "ui/gfx/size.h" | 14 #include "ui/gfx/size.h" |
16 | 15 |
17 namespace media { | 16 namespace media { |
18 | 17 |
19 // Video decoder interface. | 18 // Video decoder interface. |
20 // This interface is extended by the various components that ultimately | 19 // This interface is extended by the various components that ultimately |
21 // implement the backend of PPB_VideoDecode_Dev. | 20 // implement the backend of PPB_VideoDecode_Dev. |
22 class MEDIA_EXPORT VideoDecodeAccelerator | 21 class MEDIA_EXPORT VideoDecodeAccelerator { |
23 : public base::SupportsWeakPtr<VideoDecodeAccelerator> { | |
Ami GONE FROM CHROMIUM
2014/03/17 03:17:54
\o/
| |
24 public: | 22 public: |
25 virtual ~VideoDecodeAccelerator(); | 23 virtual ~VideoDecodeAccelerator(); |
26 | 24 |
27 // Enumeration of potential errors generated by the API. | 25 // Enumeration of potential errors generated by the API. |
28 // Note: Keep these in sync with PP_VideoDecodeError_Dev. Also do not | 26 // Note: Keep these in sync with PP_VideoDecodeError_Dev. Also do not |
29 // rearrange, reuse or remove values as they are used for gathering UMA | 27 // rearrange, reuse or remove values as they are used for gathering UMA |
30 // statistics. | 28 // statistics. |
31 enum Error { | 29 enum Error { |
32 // An operation was attempted during an incompatible decoder state. | 30 // An operation was attempted during an incompatible decoder state. |
33 ILLEGAL_STATE = 1, | 31 ILLEGAL_STATE = 1, |
34 // Invalid argument was passed to an API method. | 32 // Invalid argument was passed to an API method. |
35 INVALID_ARGUMENT, | 33 INVALID_ARGUMENT, |
36 // Encoded input is unreadable. | 34 // Encoded input is unreadable. |
37 UNREADABLE_INPUT, | 35 UNREADABLE_INPUT, |
38 // A failure occurred at the browser layer or one of its dependencies. | 36 // A failure occurred at the browser layer or one of its dependencies. |
39 // Examples of such failures include GPU hardware failures, GPU driver | 37 // Examples of such failures include GPU hardware failures, GPU driver |
40 // failures, GPU library failures, browser programming errors, and so on. | 38 // failures, GPU library failures, browser programming errors, and so on. |
41 PLATFORM_FAILURE, | 39 PLATFORM_FAILURE, |
42 // Largest used enum. This should be adjusted when new errors are added. | 40 // Largest used enum. This should be adjusted when new errors are added. |
43 LARGEST_ERROR_ENUM, | 41 LARGEST_ERROR_ENUM, |
44 }; | 42 }; |
45 | 43 |
46 // Interface for collaborating with picture interface to provide memory for | 44 // Interface for collaborating with picture interface to provide memory for |
47 // output picture and blitting them. | 45 // output picture and blitting them. |
48 // This interface is extended by the various layers that relay messages back | 46 // This interface is extended by the various layers that relay messages back |
49 // to the plugin, through the PPP_VideoDecode_Dev interface the plugin | 47 // to the plugin, through the PPP_VideoDecode_Dev interface the plugin |
50 // implements. | 48 // implements. |
51 class MEDIA_EXPORT Client { | 49 class MEDIA_EXPORT Client { |
52 public: | 50 public: |
53 // Callback to notify client that decoder has been initialized. | |
54 virtual void NotifyInitializeDone() = 0; | |
55 | |
56 // Callback to tell client how many and what size of buffers to provide. | 51 // Callback to tell client how many and what size of buffers to provide. |
57 virtual void ProvidePictureBuffers(uint32 requested_num_of_buffers, | 52 virtual void ProvidePictureBuffers(uint32 requested_num_of_buffers, |
58 const gfx::Size& dimensions, | 53 const gfx::Size& dimensions, |
59 uint32 texture_target) = 0; | 54 uint32 texture_target) = 0; |
60 | 55 |
61 // Callback to dismiss picture buffer that was assigned earlier. | 56 // Callback to dismiss picture buffer that was assigned earlier. |
62 virtual void DismissPictureBuffer(int32 picture_buffer_id) = 0; | 57 virtual void DismissPictureBuffer(int32 picture_buffer_id) = 0; |
63 | 58 |
64 // Callback to deliver decoded pictures ready to be displayed. | 59 // Callback to deliver decoded pictures ready to be displayed. |
65 virtual void PictureReady(const Picture& picture) = 0; | 60 virtual void PictureReady(const Picture& picture) = 0; |
66 | 61 |
67 // Callback to notify that decoded has decoded the end of the current | 62 // Callback to notify that decoded has decoded the end of the current |
68 // bitstream buffer. | 63 // bitstream buffer. |
69 virtual void NotifyEndOfBitstreamBuffer(int32 bitstream_buffer_id) = 0; | 64 virtual void NotifyEndOfBitstreamBuffer(int32 bitstream_buffer_id) = 0; |
70 | 65 |
71 // Flush completion callback. | 66 // Flush completion callback. |
72 virtual void NotifyFlushDone() = 0; | 67 virtual void NotifyFlushDone() = 0; |
73 | 68 |
74 // Reset completion callback. | 69 // Reset completion callback. |
75 virtual void NotifyResetDone() = 0; | 70 virtual void NotifyResetDone() = 0; |
76 | 71 |
77 // Callback to notify about decoding errors. | 72 // Callback to notify about decoding errors. |
Ami GONE FROM CHROMIUM
2014/03/17 03:17:54
Doco this can only be called after Initialize() re
sheu
2014/03/18 22:38:35
Done.
| |
78 virtual void NotifyError(Error error) = 0; | 73 virtual void NotifyError(Error error) = 0; |
79 | 74 |
80 protected: | 75 protected: |
81 virtual ~Client() {} | 76 virtual ~Client() {} |
82 }; | 77 }; |
83 | 78 |
84 // Video decoder functions. | 79 // Video decoder functions. |
85 | 80 |
86 // Initializes the video decoder with specific configuration. | 81 // Initializes the video decoder with specific configuration. Called once per |
82 // decoder construction. This call is synchronous and returns true iff | |
83 // initialization is successful. | |
87 // Parameters: | 84 // Parameters: |
88 // |profile| is the video stream's format profile. | 85 // |profile| is the video stream's format profile. |
89 // |client| is the client of this video decoder. The provided pointer must | 86 // |client| is the client of this video decoder. The provided pointer must |
90 // be valid until Destroy() is called. | 87 // be valid until Destroy() is called. |
91 // | |
92 // Returns true when command successfully accepted. Otherwise false. | |
93 virtual bool Initialize(VideoCodecProfile profile, Client* client) = 0; | 88 virtual bool Initialize(VideoCodecProfile profile, Client* client) = 0; |
94 | 89 |
95 // Decodes given bitstream buffer that contains at most one frame. Once | 90 // Decodes given bitstream buffer that contains at most one frame. Once |
96 // decoder is done with processing |bitstream_buffer| it will call | 91 // decoder is done with processing |bitstream_buffer| it will call |
97 // NotifyEndOfBitstreamBuffer() with the bitstream buffer id. | 92 // NotifyEndOfBitstreamBuffer() with the bitstream buffer id. |
98 // Parameters: | 93 // Parameters: |
99 // |bitstream_buffer| is the input bitstream that is sent for decoding. | 94 // |bitstream_buffer| is the input bitstream that is sent for decoding. |
100 virtual void Decode(const BitstreamBuffer& bitstream_buffer) = 0; | 95 virtual void Decode(const BitstreamBuffer& bitstream_buffer) = 0; |
101 | 96 |
102 // Assigns a set of texture-backed picture buffers to the video decoder. | 97 // Assigns a set of texture-backed picture buffers to the video decoder. |
103 // | 98 // |
104 // Ownership of each picture buffer remains with the client, but the client | 99 // Ownership of each picture buffer remains with the client, but the client |
105 // is not allowed to deallocate the buffer before the DismissPictureBuffer | 100 // is not allowed to deallocate the buffer before the DismissPictureBuffer |
(...skipping 27 matching lines...) Expand all Loading... | |
133 // component is freed. This call may asynchornously free system resources, | 128 // component is freed. This call may asynchornously free system resources, |
134 // but its client-visible effects are synchronous. After this method returns | 129 // but its client-visible effects are synchronous. After this method returns |
135 // no more callbacks will be made on the client. Deletes |this| | 130 // no more callbacks will be made on the client. Deletes |this| |
136 // unconditionally, so make sure to drop all pointers to it! | 131 // unconditionally, so make sure to drop all pointers to it! |
137 virtual void Destroy() = 0; | 132 virtual void Destroy() = 0; |
138 }; | 133 }; |
139 | 134 |
140 } // namespace media | 135 } // namespace media |
141 | 136 |
142 #endif // MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ | 137 #endif // MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |