| 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 | |
| 40 private: | 36 private: |
| 41 friend class base::RefCountedThreadSafe<TestVideoReceiverCallback>; | |
| 42 | |
| 43 int num_called_; | 37 int num_called_; |
| 44 }; | 38 }; |
| 45 | 39 |
| 46 class PeerVideoReceiver : public VideoReceiver { | 40 class PeerVideoReceiver : public VideoReceiver { |
| 47 public: | 41 public: |
| 48 PeerVideoReceiver(scoped_refptr<CastThread> cast_thread, | 42 PeerVideoReceiver(scoped_refptr<CastThread> cast_thread, |
| 49 const VideoReceiverConfig& video_config, | 43 const VideoReceiverConfig& video_config, |
| 50 PacedPacketSender* const packet_sender) | 44 PacedPacketSender* const packet_sender) |
| 51 : VideoReceiver(cast_thread, video_config, packet_sender) { | 45 : VideoReceiver(cast_thread, video_config, packet_sender) { |
| 52 } | 46 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 64 cast_thread_ = new CastThread(task_runner_, NULL, NULL, | 58 cast_thread_ = new CastThread(task_runner_, NULL, NULL, |
| 65 task_runner_, task_runner_); | 59 task_runner_, task_runner_); |
| 66 receiver_.reset(new | 60 receiver_.reset(new |
| 67 PeerVideoReceiver(cast_thread_, config_, &mock_transport_)); | 61 PeerVideoReceiver(cast_thread_, config_, &mock_transport_)); |
| 68 testing_clock_.Advance( | 62 testing_clock_.Advance( |
| 69 base::TimeDelta::FromMilliseconds(kStartMillisecond)); | 63 base::TimeDelta::FromMilliseconds(kStartMillisecond)); |
| 70 video_receiver_callback_ = new TestVideoReceiverCallback(); | 64 video_receiver_callback_ = new TestVideoReceiverCallback(); |
| 71 receiver_->set_clock(&testing_clock_); | 65 receiver_->set_clock(&testing_clock_); |
| 72 } | 66 } |
| 73 | 67 |
| 74 virtual ~VideoReceiverTest() {} | 68 ~VideoReceiverTest() {} |
| 75 | 69 |
| 76 virtual void SetUp() { | 70 virtual void SetUp() { |
| 77 payload_.assign(kPacketSize, 0); | 71 payload_.assign(kPacketSize, 0); |
| 78 | 72 |
| 79 // Always start with a key frame. | 73 // Always start with a key frame. |
| 80 rtp_header_.is_key_frame = true; | 74 rtp_header_.is_key_frame = true; |
| 81 rtp_header_.frame_id = 0; | 75 rtp_header_.frame_id = 0; |
| 82 rtp_header_.packet_id = 0; | 76 rtp_header_.packet_id = 0; |
| 83 rtp_header_.max_packet_id = 0; | 77 rtp_header_.max_packet_id = 0; |
| 84 rtp_header_.is_reference = false; | 78 rtp_header_.is_reference = false; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 base::Bind(&TestVideoReceiverCallback::DecodeComplete, | 129 base::Bind(&TestVideoReceiverCallback::DecodeComplete, |
| 136 video_receiver_callback_); | 130 video_receiver_callback_); |
| 137 receiver_->GetRawVideoFrame(frame_decoded_callback); | 131 receiver_->GetRawVideoFrame(frame_decoded_callback); |
| 138 task_runner_->RunTasks(); | 132 task_runner_->RunTasks(); |
| 139 } | 133 } |
| 140 | 134 |
| 141 } // namespace cast | 135 } // namespace cast |
| 142 } // namespace media | 136 } // namespace media |
| 143 | 137 |
| 144 | 138 |
| OLD | NEW |