Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / renderer / pepper / pepper_video_destination_host.h
blob7d56d058301d491b24ef36b72c62dd69179319a9
1 // Copyright (c) 2013 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.
5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_DESTINATION_HOST_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_DESTINATION_HOST_H_
8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
11 #include "content/common/content_export.h"
12 #include "content/renderer/media/webrtc/video_destination_handler.h"
13 #include "ppapi/c/pp_time.h"
14 #include "ppapi/host/resource_host.h"
16 namespace content {
18 class RendererPpapiHost;
20 class CONTENT_EXPORT PepperVideoDestinationHost
21 : public ppapi::host::ResourceHost {
22 public:
23 PepperVideoDestinationHost(RendererPpapiHost* host,
24 PP_Instance instance,
25 PP_Resource resource);
27 ~PepperVideoDestinationHost() override;
29 int32_t OnResourceMessageReceived(
30 const IPC::Message& msg,
31 ppapi::host::HostMessageContext* context) override;
33 private:
34 int32_t OnHostMsgOpen(ppapi::host::HostMessageContext* context,
35 const std::string& stream_url);
36 int32_t OnHostMsgPutFrame(ppapi::host::HostMessageContext* context,
37 const ppapi::HostResource& image_data_resource,
38 PP_TimeTicks timestamp);
39 int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context);
41 scoped_ptr<FrameWriterInterface> frame_writer_;
42 // Used for checking that timestamps are strictly increasing.
43 #if DCHECK_IS_ON()
44 bool has_received_frame_;
45 int64_t previous_timestamp_ns_;
46 #endif
48 base::WeakPtrFactory<PepperVideoDestinationHost> weak_factory_;
50 DISALLOW_COPY_AND_ASSIGN(PepperVideoDestinationHost);
53 } // namespace content
55 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_DESTINATION_HOST_H_