 Chromium Code Reviews
 Chromium Code Reviews Issue 1226123005:
  Define Stream base classes  (Closed) 
  Base URL: https://chromium.googlesource.com/external/webrtc.git@master
    
  
    Issue 1226123005:
  Define Stream base classes  (Closed) 
  Base URL: https://chromium.googlesource.com/external/webrtc.git@master| OLD | NEW | 
|---|---|
| 1 /* | 1 /* | 
| 2 * libjingle | 2 * libjingle | 
| 3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. | 
| 4 * | 4 * | 
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without | 
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: | 
| 7 * | 7 * | 
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, | 
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. | 
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 #include "webrtc/video_frame.h" | 35 #include "webrtc/video_frame.h" | 
| 36 #include "webrtc/video_receive_stream.h" | 36 #include "webrtc/video_receive_stream.h" | 
| 37 #include "webrtc/video_send_stream.h" | 37 #include "webrtc/video_send_stream.h" | 
| 38 | 38 | 
| 39 namespace cricket { | 39 namespace cricket { | 
| 40 class FakeAudioReceiveStream : public webrtc::AudioReceiveStream { | 40 class FakeAudioReceiveStream : public webrtc::AudioReceiveStream { | 
| 41 public: | 41 public: | 
| 42 explicit FakeAudioReceiveStream( | 42 explicit FakeAudioReceiveStream( | 
| 43 const webrtc::AudioReceiveStream::Config& config); | 43 const webrtc::AudioReceiveStream::Config& config); | 
| 44 | 44 | 
| 45 // webrtc::AudioReceiveStream implementation. | |
| 
pbos-webrtc
2015/07/14 14:50:14
Imo. you don't need this comment and the ones belo
 
Jelena
2015/07/15 11:12:03
I actually like to have method overrides grouped a
 | |
| 45 webrtc::AudioReceiveStream::Stats GetStats() const override; | 46 webrtc::AudioReceiveStream::Stats GetStats() const override; | 
| 46 | 47 | 
| 47 const webrtc::AudioReceiveStream::Config& GetConfig() const; | 48 const webrtc::AudioReceiveStream::Config& GetConfig() const; | 
| 48 | 49 | 
| 49 int received_packets() const { return received_packets_; } | 50 int received_packets() const { return received_packets_; } | 
| 50 void IncrementReceivedPackets(); | 51 void IncrementReceivedPackets(); | 
| 51 | 52 | 
| 52 private: | 53 private: | 
| 54 // webrtc::ReceiveStream implementation. | |
| 55 void Start() override {} | |
| 56 void Stop() override {} | |
| 57 void SignalNetworkState(webrtc::NetworkState state) override {} | |
| 58 bool DeliverRtcp(const uint8_t* packet, size_t length) override { | |
| 59 return true; | |
| 60 } | |
| 61 bool DeliverRtp(const uint8_t* packet, size_t length) override { | |
| 62 return true; | |
| 63 } | |
| 64 | |
| 53 webrtc::AudioReceiveStream::Config config_; | 65 webrtc::AudioReceiveStream::Config config_; | 
| 54 int received_packets_; | 66 int received_packets_; | 
| 55 }; | 67 }; | 
| 56 | 68 | 
| 57 class FakeVideoSendStream : public webrtc::VideoSendStream, | 69 class FakeVideoSendStream : public webrtc::VideoSendStream, | 
| 58 public webrtc::VideoCaptureInput { | 70 public webrtc::VideoCaptureInput { | 
| 59 public: | 71 public: | 
| 60 FakeVideoSendStream(const webrtc::VideoSendStream::Config& config, | 72 FakeVideoSendStream(const webrtc::VideoSendStream::Config& config, | 
| 61 const webrtc::VideoEncoderConfig& encoder_config); | 73 const webrtc::VideoEncoderConfig& encoder_config); | 
| 62 webrtc::VideoSendStream::Config GetConfig() const; | 74 webrtc::VideoSendStream::Config GetConfig() const; | 
| 63 webrtc::VideoEncoderConfig GetEncoderConfig() const; | 75 webrtc::VideoEncoderConfig GetEncoderConfig() const; | 
| 64 std::vector<webrtc::VideoStream> GetVideoStreams(); | 76 std::vector<webrtc::VideoStream> GetVideoStreams(); | 
| 65 | 77 | 
| 66 bool IsSending() const; | 78 bool IsSending() const; | 
| 67 bool GetVp8Settings(webrtc::VideoCodecVP8* settings) const; | 79 bool GetVp8Settings(webrtc::VideoCodecVP8* settings) const; | 
| 68 bool GetVp9Settings(webrtc::VideoCodecVP9* settings) const; | 80 bool GetVp9Settings(webrtc::VideoCodecVP9* settings) const; | 
| 69 | 81 | 
| 70 int GetNumberOfSwappedFrames() const; | 82 int GetNumberOfSwappedFrames() const; | 
| 71 int GetLastWidth() const; | 83 int GetLastWidth() const; | 
| 72 int GetLastHeight() const; | 84 int GetLastHeight() const; | 
| 73 void SetStats(const webrtc::VideoSendStream::Stats& stats); | 85 void SetStats(const webrtc::VideoSendStream::Stats& stats); | 
| 74 | 86 | 
| 75 private: | 87 private: | 
| 76 void IncomingCapturedFrame(const webrtc::VideoFrame& frame) override; | 88 void IncomingCapturedFrame(const webrtc::VideoFrame& frame) override; | 
| 89 | |
| 90 // webrtc::SendStream implementation. | |
| 91 void Start() override; | |
| 92 void Stop() override; | |
| 93 void SignalNetworkState(webrtc::NetworkState state) override {} | |
| 94 bool DeliverRtcp(const uint8_t* packet, size_t length) override { | |
| 95 return true; | |
| 96 } | |
| 97 | |
| 98 // webrtc::VideoSendStream implementation. | |
| 77 webrtc::VideoSendStream::Stats GetStats() override; | 99 webrtc::VideoSendStream::Stats GetStats() override; | 
| 78 | |
| 79 bool ReconfigureVideoEncoder( | 100 bool ReconfigureVideoEncoder( | 
| 80 const webrtc::VideoEncoderConfig& config) override; | 101 const webrtc::VideoEncoderConfig& config) override; | 
| 81 | |
| 82 webrtc::VideoCaptureInput* Input() override; | 102 webrtc::VideoCaptureInput* Input() override; | 
| 83 | 103 | 
| 84 void Start() override; | |
| 85 void Stop() override; | |
| 86 | |
| 87 bool sending_; | 104 bool sending_; | 
| 88 webrtc::VideoSendStream::Config config_; | 105 webrtc::VideoSendStream::Config config_; | 
| 89 webrtc::VideoEncoderConfig encoder_config_; | 106 webrtc::VideoEncoderConfig encoder_config_; | 
| 90 bool codec_settings_set_; | 107 bool codec_settings_set_; | 
| 91 union VpxSettings { | 108 union VpxSettings { | 
| 92 webrtc::VideoCodecVP8 vp8; | 109 webrtc::VideoCodecVP8 vp8; | 
| 93 webrtc::VideoCodecVP9 vp9; | 110 webrtc::VideoCodecVP9 vp9; | 
| 94 } vpx_settings_; | 111 } vpx_settings_; | 
| 95 int num_swapped_frames_; | 112 int num_swapped_frames_; | 
| 96 webrtc::VideoFrame last_frame_; | 113 webrtc::VideoFrame last_frame_; | 
| 97 webrtc::VideoSendStream::Stats stats_; | 114 webrtc::VideoSendStream::Stats stats_; | 
| 98 }; | 115 }; | 
| 99 | 116 | 
| 100 class FakeVideoReceiveStream : public webrtc::VideoReceiveStream { | 117 class FakeVideoReceiveStream : public webrtc::VideoReceiveStream { | 
| 101 public: | 118 public: | 
| 102 explicit FakeVideoReceiveStream( | 119 explicit FakeVideoReceiveStream( | 
| 103 const webrtc::VideoReceiveStream::Config& config); | 120 const webrtc::VideoReceiveStream::Config& config); | 
| 104 | 121 | 
| 105 webrtc::VideoReceiveStream::Config GetConfig(); | 122 webrtc::VideoReceiveStream::Config GetConfig(); | 
| 106 | 123 | 
| 107 bool IsReceiving() const; | 124 bool IsReceiving() const; | 
| 108 | 125 | 
| 109 void InjectFrame(const webrtc::VideoFrame& frame, int time_to_render_ms); | 126 void InjectFrame(const webrtc::VideoFrame& frame, int time_to_render_ms); | 
| 110 | 127 | 
| 111 void SetStats(const webrtc::VideoReceiveStream::Stats& stats); | 128 void SetStats(const webrtc::VideoReceiveStream::Stats& stats); | 
| 112 | 129 | 
| 113 private: | 130 private: | 
| 114 webrtc::VideoReceiveStream::Stats GetStats() const override; | 131 // webrtc::ReceiveStream implementation. | 
| 115 | |
| 116 void Start() override; | 132 void Start() override; | 
| 117 void Stop() override; | 133 void Stop() override; | 
| 134 void SignalNetworkState(webrtc::NetworkState state) override {} | |
| 135 bool DeliverRtcp(const uint8_t* packet, size_t length) override { | |
| 136 return true; | |
| 137 } | |
| 138 bool DeliverRtp(const uint8_t* packet, size_t length) override { | |
| 139 return true; | |
| 140 } | |
| 141 | |
| 142 // webrtc::VideoReceiveStream implementation. | |
| 143 webrtc::VideoReceiveStream::Stats GetStats() const override; | |
| 118 | 144 | 
| 119 webrtc::VideoReceiveStream::Config config_; | 145 webrtc::VideoReceiveStream::Config config_; | 
| 120 bool receiving_; | 146 bool receiving_; | 
| 121 webrtc::VideoReceiveStream::Stats stats_; | 147 webrtc::VideoReceiveStream::Stats stats_; | 
| 122 }; | 148 }; | 
| 123 | 149 | 
| 124 class FakeCall : public webrtc::Call, public webrtc::PacketReceiver { | 150 class FakeCall : public webrtc::Call, public webrtc::PacketReceiver { | 
| 125 public: | 151 public: | 
| 126 explicit FakeCall(const webrtc::Call::Config& config); | 152 explicit FakeCall(const webrtc::Call::Config& config); | 
| 127 ~FakeCall(); | 153 ~FakeCall() override; | 
| 128 | 154 | 
| 129 webrtc::Call::Config GetConfig() const; | 155 webrtc::Call::Config GetConfig() const; | 
| 130 const std::vector<FakeVideoSendStream*>& GetVideoSendStreams(); | 156 const std::vector<FakeVideoSendStream*>& GetVideoSendStreams(); | 
| 131 const std::vector<FakeVideoReceiveStream*>& GetVideoReceiveStreams(); | 157 const std::vector<FakeVideoReceiveStream*>& GetVideoReceiveStreams(); | 
| 132 | 158 | 
| 133 const std::vector<FakeAudioReceiveStream*>& GetAudioReceiveStreams(); | 159 const std::vector<FakeAudioReceiveStream*>& GetAudioReceiveStreams(); | 
| 134 const FakeAudioReceiveStream* GetAudioReceiveStream(uint32_t ssrc); | 160 const FakeAudioReceiveStream* GetAudioReceiveStream(uint32_t ssrc); | 
| 135 | 161 | 
| 136 webrtc::Call::NetworkState GetNetworkState() const; | 162 webrtc::NetworkState GetNetworkState() const; | 
| 137 int GetNumCreatedSendStreams() const; | 163 int GetNumCreatedSendStreams() const; | 
| 138 int GetNumCreatedReceiveStreams() const; | 164 int GetNumCreatedReceiveStreams() const; | 
| 139 void SetStats(const webrtc::Call::Stats& stats); | 165 void SetStats(const webrtc::Call::Stats& stats); | 
| 140 | 166 | 
| 141 private: | 167 private: | 
| 142 webrtc::AudioSendStream* CreateAudioSendStream( | 168 webrtc::AudioSendStream* CreateAudioSendStream( | 
| 143 const webrtc::AudioSendStream::Config& config) override; | 169 const webrtc::AudioSendStream::Config& config) override; | 
| 144 void DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) override; | 170 void DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) override; | 
| 145 | 171 | 
| 146 webrtc::AudioReceiveStream* CreateAudioReceiveStream( | 172 webrtc::AudioReceiveStream* CreateAudioReceiveStream( | 
| (...skipping 12 matching lines...) Expand all Loading... | |
| 159 webrtc::VideoReceiveStream* receive_stream) override; | 185 webrtc::VideoReceiveStream* receive_stream) override; | 
| 160 webrtc::PacketReceiver* Receiver() override; | 186 webrtc::PacketReceiver* Receiver() override; | 
| 161 | 187 | 
| 162 DeliveryStatus DeliverPacket(webrtc::MediaType media_type, | 188 DeliveryStatus DeliverPacket(webrtc::MediaType media_type, | 
| 163 const uint8_t* packet, size_t length) override; | 189 const uint8_t* packet, size_t length) override; | 
| 164 | 190 | 
| 165 webrtc::Call::Stats GetStats() const override; | 191 webrtc::Call::Stats GetStats() const override; | 
| 166 | 192 | 
| 167 void SetBitrateConfig( | 193 void SetBitrateConfig( | 
| 168 const webrtc::Call::Config::BitrateConfig& bitrate_config) override; | 194 const webrtc::Call::Config::BitrateConfig& bitrate_config) override; | 
| 169 void SignalNetworkState(webrtc::Call::NetworkState state) override; | 195 void SignalNetworkState(webrtc::NetworkState state) override; | 
| 170 | 196 | 
| 171 webrtc::Call::Config config_; | 197 webrtc::Call::Config config_; | 
| 172 webrtc::Call::NetworkState network_state_; | 198 webrtc::NetworkState network_state_; | 
| 173 webrtc::Call::Stats stats_; | 199 webrtc::Call::Stats stats_; | 
| 174 std::vector<FakeVideoSendStream*> video_send_streams_; | 200 std::vector<FakeVideoSendStream*> video_send_streams_; | 
| 175 std::vector<FakeVideoReceiveStream*> video_receive_streams_; | 201 std::vector<FakeVideoReceiveStream*> video_receive_streams_; | 
| 176 std::vector<FakeAudioReceiveStream*> audio_receive_streams_; | 202 std::vector<FakeAudioReceiveStream*> audio_receive_streams_; | 
| 177 | 203 | 
| 178 int num_created_send_streams_; | 204 int num_created_send_streams_; | 
| 179 int num_created_receive_streams_; | 205 int num_created_receive_streams_; | 
| 180 }; | 206 }; | 
| 181 | 207 | 
| 182 } // namespace cricket | 208 } // namespace cricket | 
| 183 #endif // TALK_MEDIA_WEBRTC_WEBRTCVIDEOENGINE2_UNITTEST_H_ | 209 #endif // TALK_MEDIA_WEBRTC_WEBRTCVIDEOENGINE2_UNITTEST_H_ | 
| OLD | NEW |