Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: voice_engine/channel.h

Issue 3013033002: Remove VoEFile (Closed)
Patch Set: rebase Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « voice_engine/BUILD.gn ('k') | voice_engine/channel.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 14 matching lines...) Expand all
25 #include "modules/audio_conference_mixer/include/audio_conference_mixer_defines. h" 25 #include "modules/audio_conference_mixer/include/audio_conference_mixer_defines. h"
26 #include "modules/audio_processing/rms_level.h" 26 #include "modules/audio_processing/rms_level.h"
27 #include "modules/rtp_rtcp/include/remote_ntp_time_estimator.h" 27 #include "modules/rtp_rtcp/include/remote_ntp_time_estimator.h"
28 #include "modules/rtp_rtcp/include/rtp_header_parser.h" 28 #include "modules/rtp_rtcp/include/rtp_header_parser.h"
29 #include "modules/rtp_rtcp/include/rtp_receiver.h" 29 #include "modules/rtp_rtcp/include/rtp_receiver.h"
30 #include "modules/rtp_rtcp/include/rtp_rtcp.h" 30 #include "modules/rtp_rtcp/include/rtp_rtcp.h"
31 #include "rtc_base/criticalsection.h" 31 #include "rtc_base/criticalsection.h"
32 #include "rtc_base/event.h" 32 #include "rtc_base/event.h"
33 #include "rtc_base/thread_checker.h" 33 #include "rtc_base/thread_checker.h"
34 #include "voice_engine/audio_level.h" 34 #include "voice_engine/audio_level.h"
35 #include "voice_engine/file_player.h"
36 #include "voice_engine/file_recorder.h"
37 #include "voice_engine/include/voe_base.h" 35 #include "voice_engine/include/voe_base.h"
38 #include "voice_engine/include/voe_network.h" 36 #include "voice_engine/include/voe_network.h"
39 #include "voice_engine/shared_data.h" 37 #include "voice_engine/shared_data.h"
40 #include "voice_engine/voice_engine_defines.h" 38 #include "voice_engine/voice_engine_defines.h"
41 39
42 namespace rtc { 40 namespace rtc {
43 class TimestampWrapAroundHandler; 41 class TimestampWrapAroundHandler;
44 } 42 }
45 43
46 namespace webrtc { 44 namespace webrtc {
47 45
48 class AudioDeviceModule; 46 class AudioDeviceModule;
49 class FileWrapper;
50 class PacketRouter; 47 class PacketRouter;
51 class ProcessThread; 48 class ProcessThread;
52 class RateLimiter; 49 class RateLimiter;
53 class ReceiveStatistics; 50 class ReceiveStatistics;
54 class RemoteNtpTimeEstimator; 51 class RemoteNtpTimeEstimator;
55 class RtcEventLog; 52 class RtcEventLog;
56 class RTPPayloadRegistry; 53 class RTPPayloadRegistry;
57 class RTPReceiverAudio; 54 class RTPReceiverAudio;
58 class RtpPacketReceived; 55 class RtpPacketReceived;
59 class RtpRtcp; 56 class RtpRtcp;
(...skipping 18 matching lines...) Expand all
78 class VoERtcpObserver; 75 class VoERtcpObserver;
79 76
80 // Helper class to simplify locking scheme for members that are accessed from 77 // Helper class to simplify locking scheme for members that are accessed from
81 // multiple threads. 78 // multiple threads.
82 // Example: a member can be set on thread T1 and read by an internal audio 79 // Example: a member can be set on thread T1 and read by an internal audio
83 // thread T2. Accessing the member via this class ensures that we are 80 // thread T2. Accessing the member via this class ensures that we are
84 // safe and also avoid TSan v2 warnings. 81 // safe and also avoid TSan v2 warnings.
85 class ChannelState { 82 class ChannelState {
86 public: 83 public:
87 struct State { 84 struct State {
88 bool output_file_playing = false;
89 bool input_file_playing = false;
90 bool playing = false; 85 bool playing = false;
91 bool sending = false; 86 bool sending = false;
92 }; 87 };
93 88
94 ChannelState() {} 89 ChannelState() {}
95 virtual ~ChannelState() {} 90 virtual ~ChannelState() {}
96 91
97 void Reset() { 92 void Reset() {
98 rtc::CritScope lock(&lock_); 93 rtc::CritScope lock(&lock_);
99 state_ = State(); 94 state_ = State();
100 } 95 }
101 96
102 State Get() const { 97 State Get() const {
103 rtc::CritScope lock(&lock_); 98 rtc::CritScope lock(&lock_);
104 return state_; 99 return state_;
105 } 100 }
106 101
107 void SetOutputFilePlaying(bool enable) {
108 rtc::CritScope lock(&lock_);
109 state_.output_file_playing = enable;
110 }
111
112 void SetInputFilePlaying(bool enable) {
113 rtc::CritScope lock(&lock_);
114 state_.input_file_playing = enable;
115 }
116
117 void SetPlaying(bool enable) { 102 void SetPlaying(bool enable) {
118 rtc::CritScope lock(&lock_); 103 rtc::CritScope lock(&lock_);
119 state_.playing = enable; 104 state_.playing = enable;
120 } 105 }
121 106
122 void SetSending(bool enable) { 107 void SetSending(bool enable) {
123 rtc::CritScope lock(&lock_); 108 rtc::CritScope lock(&lock_);
124 state_.sending = enable; 109 state_.sending = enable;
125 } 110 }
126 111
127 private: 112 private:
128 rtc::CriticalSection lock_; 113 rtc::CriticalSection lock_;
129 State state_; 114 State state_;
130 }; 115 };
131 116
132 class Channel 117 class Channel
133 : public RtpData, 118 : public RtpData,
134 public RtpFeedback, 119 public RtpFeedback,
135 public FileCallback, // receiving notification from file player &
136 // recorder
137 public Transport, 120 public Transport,
138 public AudioPacketizationCallback, // receive encoded packets from the 121 public AudioPacketizationCallback, // receive encoded packets from the
139 // ACM 122 // ACM
140 public MixerParticipant, // supplies output mixer with audio frames 123 public MixerParticipant, // supplies output mixer with audio frames
141 public OverheadObserver { 124 public OverheadObserver {
142 public: 125 public:
143 friend class VoERtcpObserver; 126 friend class VoERtcpObserver;
144 127
145 enum { KNumSocketThreads = 1 }; 128 enum { KNumSocketThreads = 1 };
146 enum { KNumberOfSocketBuffers = 8 }; 129 enum { KNumberOfSocketBuffers = 8 };
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // VoENetwork 193 // VoENetwork
211 int32_t RegisterExternalTransport(Transport* transport); 194 int32_t RegisterExternalTransport(Transport* transport);
212 int32_t DeRegisterExternalTransport(); 195 int32_t DeRegisterExternalTransport();
213 int32_t ReceivedRTPPacket(const uint8_t* received_packet, 196 int32_t ReceivedRTPPacket(const uint8_t* received_packet,
214 size_t length, 197 size_t length,
215 const PacketTime& packet_time); 198 const PacketTime& packet_time);
216 // TODO(nisse, solenberg): Delete when VoENetwork is deleted. 199 // TODO(nisse, solenberg): Delete when VoENetwork is deleted.
217 int32_t ReceivedRTCPPacket(const uint8_t* data, size_t length); 200 int32_t ReceivedRTCPPacket(const uint8_t* data, size_t length);
218 void OnRtpPacket(const RtpPacketReceived& packet); 201 void OnRtpPacket(const RtpPacketReceived& packet);
219 202
220 // VoEFile
221 int StartPlayingFileLocally(const char* fileName,
222 bool loop,
223 FileFormats format,
224 int startPosition,
225 float volumeScaling,
226 int stopPosition,
227 const CodecInst* codecInst);
228 int StartPlayingFileLocally(InStream* stream,
229 FileFormats format,
230 int startPosition,
231 float volumeScaling,
232 int stopPosition,
233 const CodecInst* codecInst);
234 int StopPlayingFileLocally();
235 int IsPlayingFileLocally() const;
236 int RegisterFilePlayingToMixer();
237 int StartPlayingFileAsMicrophone(const char* fileName,
238 bool loop,
239 FileFormats format,
240 int startPosition,
241 float volumeScaling,
242 int stopPosition,
243 const CodecInst* codecInst);
244 int StartPlayingFileAsMicrophone(InStream* stream,
245 FileFormats format,
246 int startPosition,
247 float volumeScaling,
248 int stopPosition,
249 const CodecInst* codecInst);
250 int StopPlayingFileAsMicrophone();
251 int IsPlayingFileAsMicrophone() const;
252 int StartRecordingPlayout(const char* fileName, const CodecInst* codecInst);
253 int StartRecordingPlayout(OutStream* stream, const CodecInst* codecInst);
254 int StopRecordingPlayout();
255
256 void SetMixWithMicStatus(bool mix);
257
258 // Muting, Volume and Level. 203 // Muting, Volume and Level.
259 void SetInputMute(bool enable); 204 void SetInputMute(bool enable);
260 void SetChannelOutputVolumeScaling(float scaling); 205 void SetChannelOutputVolumeScaling(float scaling);
261 int GetSpeechOutputLevel() const; 206 int GetSpeechOutputLevel() const;
262 int GetSpeechOutputLevelFullRange() const; 207 int GetSpeechOutputLevelFullRange() const;
263 // See description of "totalAudioEnergy" in the WebRTC stats spec: 208 // See description of "totalAudioEnergy" in the WebRTC stats spec:
264 // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaudio energy 209 // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaudio energy
265 double GetTotalOutputEnergy() const; 210 double GetTotalOutputEnergy() const;
266 double GetTotalOutputDuration() const; 211 double GetTotalOutputDuration() const;
267 212
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 MixerParticipant::AudioFrameInfo GetAudioFrameWithMuted( 286 MixerParticipant::AudioFrameInfo GetAudioFrameWithMuted(
342 int32_t id, 287 int32_t id,
343 AudioFrame* audioFrame) override; 288 AudioFrame* audioFrame) override;
344 int32_t NeededFrequency(int32_t id) const override; 289 int32_t NeededFrequency(int32_t id) const override;
345 290
346 // From AudioMixer::Source. 291 // From AudioMixer::Source.
347 AudioMixer::Source::AudioFrameInfo GetAudioFrameWithInfo( 292 AudioMixer::Source::AudioFrameInfo GetAudioFrameWithInfo(
348 int sample_rate_hz, 293 int sample_rate_hz,
349 AudioFrame* audio_frame); 294 AudioFrame* audio_frame);
350 295
351 // From FileCallback
352 void PlayNotification(int32_t id, uint32_t durationMs) override;
353 void RecordNotification(int32_t id, uint32_t durationMs) override;
354 void PlayFileEnded(int32_t id) override;
355 void RecordFileEnded(int32_t id) override;
356
357 uint32_t InstanceId() const { return _instanceId; } 296 uint32_t InstanceId() const { return _instanceId; }
358 int32_t ChannelId() const { return _channelId; } 297 int32_t ChannelId() const { return _channelId; }
359 bool Playing() const { return channel_state_.Get().playing; } 298 bool Playing() const { return channel_state_.Get().playing; }
360 bool Sending() const { return channel_state_.Get().sending; } 299 bool Sending() const { return channel_state_.Get().sending; }
361 bool ExternalTransport() const { 300 bool ExternalTransport() const {
362 rtc::CritScope cs(&_callbackCritSect); 301 rtc::CritScope cs(&_callbackCritSect);
363 return _externalTransport; 302 return _externalTransport;
364 } 303 }
365 RtpRtcp* RtpRtcpModulePtr() const { return _rtpRtcpModule.get(); } 304 RtpRtcp* RtpRtcpModulePtr() const { return _rtpRtcpModule.get(); }
366 int8_t OutputEnergyLevel() const { return _outputAudioLevel.Level(); } 305 int8_t OutputEnergyLevel() const { return _outputAudioLevel.Level(); }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 RTPHeader *header); 362 RTPHeader *header);
424 bool OnRecoveredPacket(const uint8_t* packet, size_t packet_length); 363 bool OnRecoveredPacket(const uint8_t* packet, size_t packet_length);
425 364
426 bool ReceivePacket(const uint8_t* packet, 365 bool ReceivePacket(const uint8_t* packet,
427 size_t packet_length, 366 size_t packet_length,
428 const RTPHeader& header, 367 const RTPHeader& header,
429 bool in_order); 368 bool in_order);
430 bool IsPacketInOrder(const RTPHeader& header) const; 369 bool IsPacketInOrder(const RTPHeader& header) const;
431 bool IsPacketRetransmitted(const RTPHeader& header, bool in_order) const; 370 bool IsPacketRetransmitted(const RTPHeader& header, bool in_order) const;
432 int ResendPackets(const uint16_t* sequence_numbers, int length); 371 int ResendPackets(const uint16_t* sequence_numbers, int length);
433 int32_t MixOrReplaceAudioWithFile(AudioFrame* audio_frame);
434 int32_t MixAudioWithFile(AudioFrame& audioFrame, int mixingFrequency);
435 void UpdatePlayoutTimestamp(bool rtcp); 372 void UpdatePlayoutTimestamp(bool rtcp);
436 void RegisterReceiveCodecsToRTPModule(); 373 void RegisterReceiveCodecsToRTPModule();
437 374
438 int SetSendRtpHeaderExtension(bool enable, 375 int SetSendRtpHeaderExtension(bool enable,
439 RTPExtensionType type, 376 RTPExtensionType type,
440 unsigned char id); 377 unsigned char id);
441 378
442 void UpdateOverheadForEncoder() 379 void UpdateOverheadForEncoder()
443 RTC_EXCLUSIVE_LOCKS_REQUIRED(overhead_per_packet_lock_); 380 RTC_EXCLUSIVE_LOCKS_REQUIRED(overhead_per_packet_lock_);
444 381
445 int GetRtpTimestampRateHz() const; 382 int GetRtpTimestampRateHz() const;
446 int64_t GetRTT(bool allow_associate_channel) const; 383 int64_t GetRTT(bool allow_associate_channel) const;
447 384
448 // Called on the encoder task queue when a new input audio frame is ready 385 // Called on the encoder task queue when a new input audio frame is ready
449 // for encoding. 386 // for encoding.
450 void ProcessAndEncodeAudioOnTaskQueue(AudioFrame* audio_input); 387 void ProcessAndEncodeAudioOnTaskQueue(AudioFrame* audio_input);
451 388
452 uint32_t _instanceId; 389 uint32_t _instanceId;
453 int32_t _channelId; 390 int32_t _channelId;
454 391
455 rtc::CriticalSection _fileCritSect;
456 rtc::CriticalSection _callbackCritSect; 392 rtc::CriticalSection _callbackCritSect;
457 rtc::CriticalSection volume_settings_critsect_; 393 rtc::CriticalSection volume_settings_critsect_;
458 394
459 ChannelState channel_state_; 395 ChannelState channel_state_;
460 396
461 std::unique_ptr<voe::RtcEventLogProxy> event_log_proxy_; 397 std::unique_ptr<voe::RtcEventLogProxy> event_log_proxy_;
462 std::unique_ptr<voe::RtcpRttStatsProxy> rtcp_rtt_stats_proxy_; 398 std::unique_ptr<voe::RtcpRttStatsProxy> rtcp_rtt_stats_proxy_;
463 399
464 std::unique_ptr<RtpHeaderParser> rtp_header_parser_; 400 std::unique_ptr<RtpHeaderParser> rtp_header_parser_;
465 std::unique_ptr<RTPPayloadRegistry> rtp_payload_registry_; 401 std::unique_ptr<RTPPayloadRegistry> rtp_payload_registry_;
466 std::unique_ptr<ReceiveStatistics> rtp_receive_statistics_; 402 std::unique_ptr<ReceiveStatistics> rtp_receive_statistics_;
467 std::unique_ptr<RtpReceiver> rtp_receiver_; 403 std::unique_ptr<RtpReceiver> rtp_receiver_;
468 TelephoneEventHandler* telephone_event_handler_; 404 TelephoneEventHandler* telephone_event_handler_;
469 std::unique_ptr<RtpRtcp> _rtpRtcpModule; 405 std::unique_ptr<RtpRtcp> _rtpRtcpModule;
470 std::unique_ptr<AudioCodingModule> audio_coding_; 406 std::unique_ptr<AudioCodingModule> audio_coding_;
471 acm2::CodecManager codec_manager_; 407 acm2::CodecManager codec_manager_;
472 acm2::RentACodec rent_a_codec_; 408 acm2::RentACodec rent_a_codec_;
473 std::unique_ptr<AudioSinkInterface> audio_sink_; 409 std::unique_ptr<AudioSinkInterface> audio_sink_;
474 AudioLevel _outputAudioLevel; 410 AudioLevel _outputAudioLevel;
475 bool _externalTransport; 411 bool _externalTransport;
476 // Downsamples to the codec rate if necessary. 412 // Downsamples to the codec rate if necessary.
477 PushResampler<int16_t> input_resampler_; 413 PushResampler<int16_t> input_resampler_;
478 std::unique_ptr<FilePlayer> input_file_player_;
479 std::unique_ptr<FilePlayer> output_file_player_;
480 std::unique_ptr<FileRecorder> output_file_recorder_;
481 int _inputFilePlayerId;
482 int _outputFilePlayerId;
483 int _outputFileRecorderId;
484 bool _outputFileRecording;
485 uint32_t _timeStamp RTC_ACCESS_ON(encoder_queue_); 414 uint32_t _timeStamp RTC_ACCESS_ON(encoder_queue_);
486 415
487 RemoteNtpTimeEstimator ntp_estimator_ RTC_GUARDED_BY(ts_stats_lock_); 416 RemoteNtpTimeEstimator ntp_estimator_ RTC_GUARDED_BY(ts_stats_lock_);
488 417
489 // Timestamp of the audio pulled from NetEq. 418 // Timestamp of the audio pulled from NetEq.
490 rtc::Optional<uint32_t> jitter_buffer_playout_timestamp_; 419 rtc::Optional<uint32_t> jitter_buffer_playout_timestamp_;
491 420
492 rtc::CriticalSection video_sync_lock_; 421 rtc::CriticalSection video_sync_lock_;
493 uint32_t playout_timestamp_rtp_ RTC_GUARDED_BY(video_sync_lock_); 422 uint32_t playout_timestamp_rtp_ RTC_GUARDED_BY(video_sync_lock_);
494 uint32_t playout_delay_ms_ RTC_GUARDED_BY(video_sync_lock_); 423 uint32_t playout_delay_ms_ RTC_GUARDED_BY(video_sync_lock_);
(...skipping 13 matching lines...) Expand all
508 OutputMixer* _outputMixerPtr; 437 OutputMixer* _outputMixerPtr;
509 ProcessThread* _moduleProcessThreadPtr; 438 ProcessThread* _moduleProcessThreadPtr;
510 AudioDeviceModule* _audioDeviceModulePtr; 439 AudioDeviceModule* _audioDeviceModulePtr;
511 VoiceEngineObserver* _voiceEngineObserverPtr; // owned by base 440 VoiceEngineObserver* _voiceEngineObserverPtr; // owned by base
512 rtc::CriticalSection* _callbackCritSectPtr; // owned by base 441 rtc::CriticalSection* _callbackCritSectPtr; // owned by base
513 Transport* _transportPtr; // WebRtc socket or external transport 442 Transport* _transportPtr; // WebRtc socket or external transport
514 RmsLevel rms_level_ RTC_ACCESS_ON(encoder_queue_); 443 RmsLevel rms_level_ RTC_ACCESS_ON(encoder_queue_);
515 bool input_mute_ RTC_GUARDED_BY(volume_settings_critsect_); 444 bool input_mute_ RTC_GUARDED_BY(volume_settings_critsect_);
516 bool previous_frame_muted_ RTC_ACCESS_ON(encoder_queue_); 445 bool previous_frame_muted_ RTC_ACCESS_ON(encoder_queue_);
517 float _outputGain RTC_GUARDED_BY(volume_settings_critsect_); 446 float _outputGain RTC_GUARDED_BY(volume_settings_critsect_);
518 // VoEBase
519 bool _mixFileWithMicrophone;
520 // VoeRTP_RTCP 447 // VoeRTP_RTCP
521 // TODO(henrika): can today be accessed on the main thread and on the 448 // TODO(henrika): can today be accessed on the main thread and on the
522 // task queue; hence potential race. 449 // task queue; hence potential race.
523 bool _includeAudioLevelIndication; 450 bool _includeAudioLevelIndication;
524 size_t transport_overhead_per_packet_ 451 size_t transport_overhead_per_packet_
525 RTC_GUARDED_BY(overhead_per_packet_lock_); 452 RTC_GUARDED_BY(overhead_per_packet_lock_);
526 size_t rtp_overhead_per_packet_ RTC_GUARDED_BY(overhead_per_packet_lock_); 453 size_t rtp_overhead_per_packet_ RTC_GUARDED_BY(overhead_per_packet_lock_);
527 rtc::CriticalSection overhead_per_packet_lock_; 454 rtc::CriticalSection overhead_per_packet_lock_;
528 // VoENetwork 455 // VoENetwork
529 AudioFrame::SpeechType _outputSpeechType; 456 AudioFrame::SpeechType _outputSpeechType;
(...skipping 23 matching lines...) Expand all
553 480
554 bool encoder_queue_is_active_ RTC_GUARDED_BY(encoder_queue_lock_) = false; 481 bool encoder_queue_is_active_ RTC_GUARDED_BY(encoder_queue_lock_) = false;
555 482
556 rtc::TaskQueue* encoder_queue_ = nullptr; 483 rtc::TaskQueue* encoder_queue_ = nullptr;
557 }; 484 };
558 485
559 } // namespace voe 486 } // namespace voe
560 } // namespace webrtc 487 } // namespace webrtc
561 488
562 #endif // VOICE_ENGINE_CHANNEL_H_ 489 #endif // VOICE_ENGINE_CHANNEL_H_
OLDNEW
« no previous file with comments | « voice_engine/BUILD.gn ('k') | voice_engine/channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698