This source file includes following definitions.
- Create
- provider_
- Stop
- AcquireLockAndCurrentFrame
- PutCurrentFrame
- ReleaseLock
- StopUsingProvider
- DidReceiveFrame
- DidUpdateMatrix
#include "cc/layers/video_frame_provider_client_impl.h"
#include "cc/base/math_util.h"
#include "cc/layers/video_layer_impl.h"
#include "media/base/video_frame.h"
namespace cc {
scoped_refptr<VideoFrameProviderClientImpl>
VideoFrameProviderClientImpl::Create(
VideoFrameProvider* provider) {
return make_scoped_refptr(
new VideoFrameProviderClientImpl(provider));
}
VideoFrameProviderClientImpl::~VideoFrameProviderClientImpl() {}
VideoFrameProviderClientImpl::VideoFrameProviderClientImpl(
VideoFrameProvider* provider)
: active_video_layer_(NULL), provider_(provider) {
provider_->SetVideoFrameProviderClient(this);
stream_texture_matrix_ = gfx::Transform(
1.0, 0.0, 0.0, 0.0,
0.0, -1.0, 0.0, 1.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0);
}
void VideoFrameProviderClientImpl::Stop() {
if (!provider_)
return;
provider_->SetVideoFrameProviderClient(NULL);
provider_ = NULL;
}
scoped_refptr<media::VideoFrame>
VideoFrameProviderClientImpl::AcquireLockAndCurrentFrame() {
provider_lock_.Acquire();
if (!provider_)
return NULL;
return provider_->GetCurrentFrame();
}
void VideoFrameProviderClientImpl::PutCurrentFrame(
const scoped_refptr<media::VideoFrame>& frame) {
provider_lock_.AssertAcquired();
provider_->PutCurrentFrame(frame);
}
void VideoFrameProviderClientImpl::ReleaseLock() {
provider_lock_.AssertAcquired();
provider_lock_.Release();
}
void VideoFrameProviderClientImpl::StopUsingProvider() {
base::AutoLock locker(provider_lock_);
provider_ = NULL;
}
void VideoFrameProviderClientImpl::DidReceiveFrame() {
if (active_video_layer_)
active_video_layer_->SetNeedsRedraw();
}
void VideoFrameProviderClientImpl::DidUpdateMatrix(const float* matrix) {
stream_texture_matrix_ = gfx::Transform(
matrix[0], matrix[4], matrix[8], matrix[12],
matrix[1], matrix[5], matrix[9], matrix[13],
matrix[2], matrix[6], matrix[10], matrix[14],
matrix[3], matrix[7], matrix[11], matrix[15]);
if (active_video_layer_)
active_video_layer_->SetNeedsRedraw();
}
}