OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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 #include "ppapi/cpp/video_encoder_client.h" |
| 6 |
| 7 #include "ppapi/cpp/instance.h" |
| 8 #include "ppapi/cpp/instance_handle.h" |
| 9 #include "ppapi/cpp/module.h" |
| 10 #include "ppapi/cpp/module_impl.h" |
| 11 #include "ppapi/cpp/video_encoder.h" |
| 12 |
| 13 namespace pp { |
| 14 |
| 15 namespace { |
| 16 |
| 17 const char kPPPVideoEncoderInterface[] = PPP_VIDEOENCODER_INTERFACE_0_1; |
| 18 |
| 19 void HandleBitstreamBuffer(PP_Instance instance, |
| 20 PP_Resource encoder, |
| 21 const PP_VideoEncoderBitstreamBuffer* buffer) { |
| 22 void* object = Instance::GetPerInstanceObject(instance, |
| 23 kPPPVideoEncoderInterface); |
| 24 if (!object) |
| 25 return; |
| 26 static_cast<VideoEncoderClient*>(object)->HandleBitstreamBuffer( |
| 27 VideoEncoder(encoder), *buffer); |
| 28 } |
| 29 |
| 30 static PPP_VideoEncoder_0_1 videoencoder_interface = { |
| 31 &HandleBitstreamBuffer, |
| 32 }; |
| 33 |
| 34 } // namespace |
| 35 |
| 36 VideoEncoderClient::VideoEncoderClient(Instance* instance) |
| 37 : associated_instance_(instance) { |
| 38 Module::Get()->AddPluginInterface(kPPPVideoEncoderInterface, |
| 39 &videoencoder_interface); |
| 40 instance->AddPerInstanceObject(kPPPVideoEncoderInterface, this); |
| 41 } |
| 42 |
| 43 VideoEncoderClient::~VideoEncoderClient() { |
| 44 Instance::RemovePerInstanceObject(associated_instance_, |
| 45 kPPPVideoEncoderInterface, this); |
| 46 } |
| 47 |
| 48 } // namespace pp |
OLD | NEW |