Index: ppapi/cpp/video_encoder_client.cc |
diff --git a/ppapi/cpp/video_encoder_client.cc b/ppapi/cpp/video_encoder_client.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c93580860bb8139f691b3ac6821c2d6ffadaeb86 |
--- /dev/null |
+++ b/ppapi/cpp/video_encoder_client.cc |
@@ -0,0 +1,48 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "ppapi/cpp/video_encoder_client.h" |
+ |
+#include "ppapi/cpp/instance.h" |
+#include "ppapi/cpp/instance_handle.h" |
+#include "ppapi/cpp/module.h" |
+#include "ppapi/cpp/module_impl.h" |
+#include "ppapi/cpp/video_encoder.h" |
+ |
+namespace pp { |
+ |
+namespace { |
+ |
+const char kPPPVideoEncoderInterface[] = PPP_VIDEOENCODER_INTERFACE_0_1; |
+ |
+void HandleBitstreamBuffer(PP_Instance instance, |
+ PP_Resource encoder, |
+ const PP_VideoEncoderBitstreamBuffer* buffer) { |
+ void* object = Instance::GetPerInstanceObject(instance, |
+ kPPPVideoEncoderInterface); |
+ if (!object) |
+ return; |
+ static_cast<VideoEncoderClient*>(object)->HandleBitstreamBuffer( |
+ VideoEncoder(encoder), *buffer); |
+} |
+ |
+static PPP_VideoEncoder_0_1 videoencoder_interface = { |
+ &HandleBitstreamBuffer, |
+}; |
+ |
+} // namespace |
+ |
+VideoEncoderClient::VideoEncoderClient(Instance* instance) |
+ : associated_instance_(instance) { |
+ Module::Get()->AddPluginInterface(kPPPVideoEncoderInterface, |
+ &videoencoder_interface); |
+ instance->AddPerInstanceObject(kPPPVideoEncoderInterface, this); |
+} |
+ |
+VideoEncoderClient::~VideoEncoderClient() { |
+ Instance::RemovePerInstanceObject(associated_instance_, |
+ kPPPVideoEncoderInterface, this); |
+} |
+ |
+} // namespace pp |