OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/test/simple_test_tick_clock.h" | 8 #include "base/test/simple_test_tick_clock.h" |
9 #include "media/cast/cast_defines.h" | 9 #include "media/cast/cast_defines.h" |
10 #include "media/cast/cast_thread.h" | 10 #include "media/cast/cast_thread.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 public base::RefCountedThreadSafe<TestVideoReceiverCallback> { | 26 public base::RefCountedThreadSafe<TestVideoReceiverCallback> { |
27 public: | 27 public: |
28 TestVideoReceiverCallback() | 28 TestVideoReceiverCallback() |
29 :num_called_(0) {} | 29 :num_called_(0) {} |
30 // TODO(mikhal): Set and check expectations. | 30 // TODO(mikhal): Set and check expectations. |
31 void DecodeComplete(scoped_ptr<I420VideoFrame> frame, | 31 void DecodeComplete(scoped_ptr<I420VideoFrame> frame, |
32 const base::TimeTicks render_time) { | 32 const base::TimeTicks render_time) { |
33 ++num_called_; | 33 ++num_called_; |
34 } | 34 } |
35 int number_times_called() { return num_called_;} | 35 int number_times_called() { return num_called_;} |
| 36 |
| 37 protected: |
| 38 virtual ~TestVideoReceiverCallback() {} |
| 39 |
36 private: | 40 private: |
| 41 friend class base::RefCountedThreadSafe<TestVideoReceiverCallback>; |
| 42 |
37 int num_called_; | 43 int num_called_; |
38 }; | 44 }; |
39 | 45 |
40 class PeerVideoReceiver : public VideoReceiver { | 46 class PeerVideoReceiver : public VideoReceiver { |
41 public: | 47 public: |
42 PeerVideoReceiver(scoped_refptr<CastThread> cast_thread, | 48 PeerVideoReceiver(scoped_refptr<CastThread> cast_thread, |
43 const VideoReceiverConfig& video_config, | 49 const VideoReceiverConfig& video_config, |
44 PacedPacketSender* const packet_sender) | 50 PacedPacketSender* const packet_sender) |
45 : VideoReceiver(cast_thread, video_config, packet_sender) { | 51 : VideoReceiver(cast_thread, video_config, packet_sender) { |
46 } | 52 } |
(...skipping 11 matching lines...) Expand all Loading... |
58 cast_thread_ = new CastThread(task_runner_, NULL, NULL, | 64 cast_thread_ = new CastThread(task_runner_, NULL, NULL, |
59 task_runner_, task_runner_); | 65 task_runner_, task_runner_); |
60 receiver_.reset(new | 66 receiver_.reset(new |
61 PeerVideoReceiver(cast_thread_, config_, &mock_transport_)); | 67 PeerVideoReceiver(cast_thread_, config_, &mock_transport_)); |
62 testing_clock_.Advance( | 68 testing_clock_.Advance( |
63 base::TimeDelta::FromMilliseconds(kStartMillisecond)); | 69 base::TimeDelta::FromMilliseconds(kStartMillisecond)); |
64 video_receiver_callback_ = new TestVideoReceiverCallback(); | 70 video_receiver_callback_ = new TestVideoReceiverCallback(); |
65 receiver_->set_clock(&testing_clock_); | 71 receiver_->set_clock(&testing_clock_); |
66 } | 72 } |
67 | 73 |
68 ~VideoReceiverTest() {} | 74 virtual ~VideoReceiverTest() {} |
69 | 75 |
70 virtual void SetUp() { | 76 virtual void SetUp() { |
71 payload_.assign(kPacketSize, 0); | 77 payload_.assign(kPacketSize, 0); |
72 | 78 |
73 // Always start with a key frame. | 79 // Always start with a key frame. |
74 rtp_header_.is_key_frame = true; | 80 rtp_header_.is_key_frame = true; |
75 rtp_header_.frame_id = 0; | 81 rtp_header_.frame_id = 0; |
76 rtp_header_.packet_id = 0; | 82 rtp_header_.packet_id = 0; |
77 rtp_header_.max_packet_id = 0; | 83 rtp_header_.max_packet_id = 0; |
78 rtp_header_.is_reference = false; | 84 rtp_header_.is_reference = false; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 base::Bind(&TestVideoReceiverCallback::DecodeComplete, | 135 base::Bind(&TestVideoReceiverCallback::DecodeComplete, |
130 video_receiver_callback_); | 136 video_receiver_callback_); |
131 receiver_->GetRawVideoFrame(frame_decoded_callback); | 137 receiver_->GetRawVideoFrame(frame_decoded_callback); |
132 task_runner_->RunTasks(); | 138 task_runner_->RunTasks(); |
133 } | 139 } |
134 | 140 |
135 } // namespace cast | 141 } // namespace cast |
136 } // namespace media | 142 } // namespace media |
137 | 143 |
138 | 144 |
OLD | NEW |