Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / webrtc / modules / video_coding / main / test / mt_test_common.h
1 /*
2  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10
11 /*
12  * Common multi-thread functionality across video coding module tests
13  */
14
15 #ifndef WEBRTC_MODULES_VIDEO_CODING_TEST_MT_TEST_COMMON_H_
16 #define WEBRTC_MODULES_VIDEO_CODING_TEST_MT_TEST_COMMON_H_
17
18 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h"
19 #include "webrtc/modules/video_coding/main/interface/video_coding.h"
20 #include "webrtc/modules/video_coding/main/test/test_callbacks.h"
21 #include "webrtc/modules/video_coding/main/test/video_source.h"
22
23 namespace webrtc {
24
25 class SendSharedState
26 {
27 public:
28     SendSharedState(webrtc::VideoCodingModule& vcm, webrtc::RtpRtcp& rtp,
29             CmdArgs args) :
30             _vcm(vcm),
31             _rtp(rtp),
32             _args(args),
33             _sourceFile(NULL),
34             _frameCnt(0),
35             _timestamp(0) {}
36
37     webrtc::VideoCodingModule&  _vcm;
38     webrtc::RtpRtcp&            _rtp;
39     CmdArgs                     _args;
40     FILE*                       _sourceFile;
41     int32_t               _frameCnt;
42     int32_t               _timestamp;
43 };
44
45 // MT implementation of the RTPSendCompleteCallback (Transport)
46 class TransportCallback:public RTPSendCompleteCallback
47 {
48  public:
49     // constructor input: (receive side) rtp module to send encoded data to
50     TransportCallback(Clock* clock, const char* filename = NULL);
51     virtual ~TransportCallback();
52     // Add packets to list
53     // Incorporate network conditions - delay and packet loss
54     // Actual transmission will occur on a separate thread
55     virtual int SendPacket(int channel, const void *data, int len) OVERRIDE;
56     // Send to the receiver packets which are ready to be submitted
57     int TransportPackets();
58 };
59
60 class SharedRTPState
61 {
62 public:
63     SharedRTPState(webrtc::VideoCodingModule& vcm, webrtc::RtpRtcp& rtp) :
64         _vcm(vcm),
65         _rtp(rtp) {}
66     webrtc::VideoCodingModule&  _vcm;
67     webrtc::RtpRtcp&            _rtp;
68 };
69
70
71 class SharedTransportState
72 {
73 public:
74     SharedTransportState(webrtc::RtpRtcp& rtp, TransportCallback& transport):
75         _rtp(rtp),
76         _transport(transport) {}
77     webrtc::RtpRtcp&            _rtp;
78     TransportCallback&          _transport;
79 };
80
81 bool VCMProcessingThread(void* obj);
82 bool VCMDecodeThread(void* obj);
83 bool TransportThread(void *obj);
84
85 }  // namespace webrtc
86
87 #endif  // WEBRTC_MODULES_VIDEO_CODING_TEST_MT_TEST_COMMON_H_