// Video encoder interface.
class MEDIA_EXPORT VideoEncodeAccelerator {
public:
- virtual ~VideoEncodeAccelerator();
-
// Specification of an encoding profile supported by an encoder.
struct SupportedProfile {
VideoCodecProfile profile;
gfx::Size max_resolution;
- struct {
- uint32 numerator;
- uint32 denominator;
- } max_framerate;
+ uint32 max_framerate_numerator;
+ uint32 max_framerate_denominator;
};
// Enumeration of potential errors generated by the API.
kErrorMax = kPlatformFailureError
};
- // Interface for clients that use VideoEncodeAccelerator.
+ // Interface for clients that use VideoEncodeAccelerator. These callbacks will
+ // not be made unless Initialize() has returned successfully.
class MEDIA_EXPORT Client {
public:
- // Callback to notify client that encoder has been successfully initialized.
- virtual void NotifyInitializeDone() = 0;
-
// Callback to tell the client what size of frames and buffers to provide
// for input and output. The VEA disclaims use or ownership of all
// previously provided buffers once this callback is made.
size_t payload_size,
bool key_frame) = 0;
- // Error notification callback.
+ // Error notification callback. Note that errors in Initialize() will not be
+ // reported here, but will instead be indicated by a false return value
+ // there.
virtual void NotifyError(Error error) = 0;
protected:
// Video encoder functions.
- // Initialize the video encoder with a specific configuration. Called once
- // per encoder construction.
+ // Returns a list of the supported codec profiles of the video encoder. This
+ // can be called before Initialize().
+ virtual std::vector<SupportedProfile> GetSupportedProfiles() = 0;
+
+ // Initializes the video encoder with specific configuration. Called once per
+ // encoder construction. This call is synchronous and returns true iff
+ // initialization is successful.
// Parameters:
// |input_format| is the frame format of the input stream (as would be
// reported by VideoFrame::format() for frames passed to Encode()).
// |client| is the client of this video encoder. The provided pointer must
// be valid until Destroy() is called.
// TODO(sheu): handle resolution changes. http://crbug.com/249944
- virtual void Initialize(VideoFrame::Format input_format,
+ virtual bool Initialize(VideoFrame::Format input_format,
const gfx::Size& input_visible_size,
VideoCodecProfile output_profile,
uint32 initial_bitrate,
// this method returns no more callbacks will be made on the client. Deletes
// |this| unconditionally, so make sure to drop all pointers to it!
virtual void Destroy() = 0;
+
+ protected:
+ // Do not delete directly; use Destroy() or own it with a scoped_ptr, which
+ // will Destroy() it properly by default.
+ virtual ~VideoEncodeAccelerator();
};
} // namespace media
+namespace base {
+
+template <class T>
+struct DefaultDeleter;
+
+// Specialize DefaultDeleter so that scoped_ptr<VideoEncodeAccelerator> always
+// uses "Destroy()" instead of trying to use the destructor.
+template <>
+struct MEDIA_EXPORT DefaultDeleter<media::VideoEncodeAccelerator> {
+ public:
+ void operator()(void* video_encode_accelerator) const;
+};
+
+} // namespace base
+
#endif // MEDIA_VIDEO_VIDEO_ENCODE_ACCELERATOR_H_