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

Side by Side Diff: media/video/video_encode_accelerator.h

Issue 20632002: Add media::VideoEncodeAccelerator with WebRTC integration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@git-svn
Patch Set: 2247fd82 Rebase. Created 7 years, 4 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 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 browser layer or one of its dependencies.
44 // Examples of such failures include GPU hardware failures, GPU driver
45 // failures, GPU library failures, browser programming errors, and so on.
46 kPlatformFailureError,
47 };
48
49 // Interface for clients that use VideoEncodeAccelerator.
50 class MEDIA_EXPORT Client {
51 public:
52 // Callback to notify client that encoder has been successfully initialized.
53 virtual void NotifyInitializeDone() = 0;
54
55 // Callback to tell the client what size of buffers to provide for input and
56 // output. The VEA disclaims use or ownership of all previously provided
57 // buffers once this callback is made.
58 // Parameters:
59 // |input_count| is the number of input frames required for encoding. The
60 // client should provide at least this many frames, since the encoder may
61 // need to hold onto some subset of inputs as reference pictures.
62 // |input_dimensions| are the logical dimensions of the input frames to
63 // encode, in pixels. The encoder may have hardware alignment requirements
64 // that make this different from |input_resolution|, as requested in
65 // Initialize(), in which case the input buffer should be padded to
66 // |input_dimensions|.
67 // |output_size| is the required size of output buffers for this encoder,
68 // in bytes.
69 virtual void RequireBitstreamBuffers(int input_count,
70 const gfx::Size& input_dimensions,
71 size_t output_size) = 0;
72
73 // Callback to notify that encoder has finished with an input frame.
74 virtual void NotifyInputDone(int32 bitstream_buffer_id) = 0;
75
76 // Callback to deliver encoded bitstream buffers. The VEA disclaims use or
77 // ownership of the specified buffer once this callback is made.
78 // |bitstream_buffer_id| is the id of the buffer that is ready.
79 // |size| is the byte size of the used portion of the buffer.
80 virtual void BitstreamBufferReady(int32 bitstream_buffer_id,
81 size_t payload_size,
82 bool key_frame) = 0;
83
84 // Error notification callback.
85 virtual void NotifyError(Error error) = 0;
86
87 protected:
88 virtual ~Client() {}
89 };
90
91 // Video encoder functions.
92
93 // Initialize the video encoder with a specific configuration. Called once
94 // per encoder construction.
95 // Parameters:
96 // |input_format| is the frame format of the input stream.
97 // |input_resolution| is the resolution of the input stream.
98 // |output_profile| is the codec profile of the encoded output stream.
99 // |initial_bitrate| is the initial bitrate of the encoded output stream,
100 // in bits per second.
101 virtual void Initialize(media::VideoFrame::Format input_format,
102 const gfx::Size& input_resolution,
103 VideoCodecProfile output_profile,
104 int32 initial_bitrate) = 0;
105
106 // Encodes the given frame.
107 // Parameters:
108 // |buffer| is the buffer holding the frame that is to be encoded (with a
109 // buffer logical size/width as specified in RequireBitstreamBuffers(), and
110 // visible size/width as specified in Initialize()).
111 // |force_keyframe| forces the encoding of a keyframe for this frame.
112 virtual void Encode(const BitstreamBuffer& buffer, bool force_keyframe) = 0;
113
114 // Send a bitstream buffer to the encoder to be used for storing future
115 // encoded output.
116 // Parameters:
117 // |buffer| is the bitstream buffer to use for output.
118 virtual void UseOutputBitstreamBuffer(const BitstreamBuffer& buffer) = 0;
119
120 // Request a change to the encoding parameters. This is only a request,
121 // fulfilled on a best-effort basis.
122 // Parameters:
123 // |bitrate| is the requested new bitrate, in bits per second.
124 virtual void RequestEncodingParameterChange(int32 bitrate) = 0;
125
126 // Destroys the encoder: all pending inputs are dropped immediately and the
127 // component is freed. This call may asynchronously free system resources,
128 // but its client-visible effects are synchronous. After this method returns
129 // no more callbacks will be made on the client. Deletes |this|
130 // unconditionally, so make sure to drop all pointers to it!
131 virtual void Destroy() = 0;
132 };
133
134 } // namespace media
135
136 #endif // MEDIA_VIDEO_VIDEO_ENCODE_ACCELERATOR_H_
OLDNEW
« media/media.gyp ('K') | « media/media.gyp ('k') | media/video/video_encode_accelerator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698