OLD | NEW |
---|---|
(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 MEDIA_VIDEO_VIDEO_ENCODE_ACCELERATOR_H_ | |
6 #define MEDIA_VIDEO_VIDEO_ENCODE_ACCELERATOR_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/memory/ref_counted.h" | |
12 #include "media/base/bitstream_buffer.h" | |
13 #include "media/base/media_export.h" | |
14 #include "media/base/video_decoder_config.h" | |
15 #include "media/base/video_frame.h" | |
16 | |
17 namespace media { | |
18 | |
19 class BitstreamBuffer; | |
20 class VideoFrame; | |
21 | |
22 // Video encoder interface. | |
23 class MEDIA_EXPORT VideoEncodeAccelerator { | |
24 public: | |
25 virtual ~VideoEncodeAccelerator(); | |
26 | |
27 // Specification of an encoding profile supported by an encoder. | |
28 struct SupportedProfile { | |
29 VideoCodecProfile profile; | |
30 gfx::Size max_resolution; | |
31 struct { | |
32 uint32 numerator; | |
33 uint32 denominator; | |
34 } max_framerate; | |
35 }; | |
36 | |
37 // Enumeration of potential errors generated by the API. | |
38 enum Error { | |
39 // An operation was attempted during an incompatible encoder state. | |
40 kIllegalStateError, | |
41 // Invalid argument was passed to an API method. | |
42 kInvalidArgumentError, | |
43 // A failure occurred at the GPU process or one of its dependencies. | |
44 // Examples of such failures include GPU hardware failures, GPU driver | |
45 // failures, GPU library failures, GPU process programming errors, and so | |
46 // on. | |
47 kPlatformFailureError, | |
48 }; | |
49 | |
50 // Interface for clients that use VideoEncodeAccelerator. | |
51 class MEDIA_EXPORT Client { | |
52 public: | |
53 // Callback to notify client that encoder has been successfully initialized. | |
54 virtual void NotifyInitializeDone() = 0; | |
55 | |
56 // Callback to tell the client what size of frames and buffers to provide | |
57 // for input and output. The VEA disclaims use or ownership of all | |
58 // previously provided buffers once this callback is made. | |
59 // Parameters: | |
60 // |input_count| is the number of input VideoFrames required for encoding. | |
61 // The client should provide at least this many frames, since the encoder | |
62 // may need to hold onto some subset of inputs as reference pictures. | |
Ami GONE FROM CHROMIUM
2013/08/05 18:44:38
"provide at least this many frames" sounds like th
sheu
2013/08/06 06:16:36
Done (comment)
RequireBitstreamBuffers() is calle
| |
63 // |input_coded_size| is the logical size of the input frames (as reported | |
64 // by VideoFrame::coded_size()) to encode, in pixels. The encoder may have | |
65 // hardware alignment requirements that make this different from | |
66 // |input_visible_size|, as requested in Initialize(), in which case the | |
67 // input VideoFrame to Encode() should be padded appropriately. | |
Ami GONE FROM CHROMIUM
2013/08/05 18:44:38
I love this comment. I wish all comments were lik
| |
68 // |output_buffer_size| is the required size of output buffers for this | |
69 // encoder in bytes. | |
Ami GONE FROM CHROMIUM
2013/08/05 18:44:38
How does the client know how many buffers of this
sheu
2013/08/06 06:16:36
It can provide as many or few as it wants, > 0.
| |
70 virtual void RequireBitstreamBuffers(int input_count, | |
71 const gfx::Size& input_coded_size, | |
72 size_t output_buffer_size) = 0; | |
73 | |
74 // Callback to deliver encoded bitstream buffers. The VEA disclaims use or | |
75 // ownership of the specified buffer once this callback is made. | |
76 // |bitstream_buffer_id| is the id of the buffer that is ready. | |
77 // |payload_size| is the byte size of the used portion of the buffer. | |
78 // |key_frame| is true if this delivered frame is a keyframe. | |
Ami GONE FROM CHROMIUM
2013/08/05 18:44:38
I think you missed my comment:
On 2013/07/31 23:01
sheu
2013/08/06 06:16:36
Done.
| |
79 virtual void BitstreamBufferReady(int32 bitstream_buffer_id, | |
80 size_t payload_size, | |
81 bool key_frame) = 0; | |
82 | |
83 // Error notification callback. | |
84 virtual void NotifyError(Error error) = 0; | |
85 | |
86 protected: | |
Ami GONE FROM CHROMIUM
2013/08/05 18:44:38
If you want to be providing a service here then ma
sheu
2013/08/06 06:16:36
Done. Has to be protected though or nothing can i
| |
87 virtual ~Client() {} | |
88 }; | |
89 | |
90 // Video encoder functions. | |
91 | |
92 // Initialize the video encoder with a specific configuration. Called once | |
93 // per encoder construction. | |
94 // Parameters: | |
95 // |input_format| is the frame format of the input stream (as would be | |
96 // reported by VideoFrame::format() for frames passed to Encode()). | |
Ami GONE FROM CHROMIUM
2013/08/05 18:44:38
I don't think that's right. Here are two examples
sheu
2013/08/06 06:16:36
Oh. Hmm. In that case we should just have RTCVid
| |
97 // |input_visible_size| is the resolution of the input stream (as would be | |
98 // reported by VideoFrame::visible_rect().size() for frames passed to | |
99 // Encode()). | |
100 // |output_profile| is the codec profile of the encoded output stream. | |
101 // |initial_bitrate| is the initial bitrate of the encoded output stream, | |
102 // in bits per second. | |
103 virtual void Initialize(media::VideoFrame::Format input_format, | |
104 const gfx::Size& input_visible_size, | |
105 VideoCodecProfile output_profile, | |
106 int32 initial_bitrate) = 0; | |
107 | |
108 // Encodes the given frame. | |
109 // Parameters: | |
110 // |frame| is the VideoFrame that is to be encoded. | |
111 // |force_keyframe| forces the encoding of a keyframe for this frame. | |
112 virtual void Encode(const scoped_refptr<VideoFrame>& frame, | |
113 bool force_keyframe) = 0; | |
114 | |
115 // Send a bitstream buffer to the encoder to be used for storing future | |
116 // encoded output. | |
Ami GONE FROM CHROMIUM
2013/08/05 18:44:38
This sounds one-off'ish, but in reality must be ca
sheu
2013/08/06 06:16:36
Done.
| |
117 // Parameters: | |
118 // |buffer| is the bitstream buffer to use for output. | |
119 virtual void UseOutputBitstreamBuffer(const BitstreamBuffer& buffer) = 0; | |
120 | |
121 // Request a change to the encoding parameters. This is only a request, | |
122 // fulfilled on a best-effort basis. | |
123 // Parameters: | |
124 // |bitrate| is the requested new bitrate, in bits per second. | |
125 virtual void RequestEncodingParameterChange(int32 bitrate) = 0; | |
126 | |
127 // Destroys the encoder: all pending inputs and outputs are dropped | |
128 // immediately and the component is freed. This call may asynchornously free | |
Ami GONE FROM CHROMIUM
2013/08/05 18:44:38
typo: asynchornously
sheu
2013/08/06 06:16:36
Done.
| |
129 // system resources, but its client-visible effects are synchronous. After | |
130 // this method returns no more callbacks will be made on the client. Deletes | |
131 // |this| unconditionally, so make sure to drop all pointers to it! | |
132 virtual void Destroy() = 0; | |
133 }; | |
134 | |
135 } // namespace media | |
136 | |
137 #endif // MEDIA_VIDEO_VIDEO_ENCODE_ACCELERATOR_H_ | |
OLD | NEW |