Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / media / video / video_encode_accelerator.h
index 169d124..9551c22 100644 (file)
@@ -22,16 +22,12 @@ class VideoFrame;
 // 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.
@@ -48,12 +44,10 @@ class MEDIA_EXPORT VideoEncodeAccelerator {
     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.
@@ -83,7 +77,9 @@ class MEDIA_EXPORT VideoEncodeAccelerator {
                                       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:
@@ -94,8 +90,13 @@ class MEDIA_EXPORT VideoEncodeAccelerator {
 
   // 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()).
@@ -108,7 +109,7 @@ class MEDIA_EXPORT VideoEncodeAccelerator {
   //  |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,
@@ -142,8 +143,28 @@ class MEDIA_EXPORT VideoEncodeAccelerator {
   // 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_