OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2004 Google Inc. | 3 * Copyright 2004 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 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1298 // callback. | 1298 // callback. |
1299 // This method is called on the libjingle worker thread. | 1299 // This method is called on the libjingle worker thread. |
1300 // TODO(xians): Make sure Start() is called only once. | 1300 // TODO(xians): Make sure Start() is called only once. |
1301 void Start(AudioRenderer* renderer) { | 1301 void Start(AudioRenderer* renderer) { |
1302 rtc::CritScope lock(&lock_); | 1302 rtc::CritScope lock(&lock_); |
1303 RTC_DCHECK(renderer != NULL); | 1303 RTC_DCHECK(renderer != NULL); |
1304 if (renderer_ != NULL) { | 1304 if (renderer_ != NULL) { |
1305 RTC_DCHECK(renderer_ == renderer); | 1305 RTC_DCHECK(renderer_ == renderer); |
1306 return; | 1306 return; |
1307 } | 1307 } |
| 1308 |
| 1309 // TODO(xians): Remove AddChannel() call after Chrome turns on APM |
| 1310 // in getUserMedia by default. |
| 1311 renderer->AddChannel(channel_); |
1308 renderer->SetSink(this); | 1312 renderer->SetSink(this); |
1309 renderer_ = renderer; | 1313 renderer_ = renderer; |
1310 } | 1314 } |
1311 | 1315 |
1312 // Stops rendering by setting the sink of the renderer to NULL. No data | 1316 // Stops rendering by setting the sink of the renderer to NULL. No data |
1313 // callback will be received after this method. | 1317 // callback will be received after this method. |
1314 // This method is called on the libjingle worker thread. | 1318 // This method is called on the libjingle worker thread. |
1315 void Stop() { | 1319 void Stop() { |
1316 rtc::CritScope lock(&lock_); | 1320 rtc::CritScope lock(&lock_); |
1317 if (renderer_ != NULL) { | 1321 if (renderer_ == NULL) |
1318 renderer_->SetSink(NULL); | 1322 return; |
1319 renderer_ = NULL; | 1323 |
1320 } | 1324 renderer_->RemoveChannel(channel_); |
| 1325 renderer_->SetSink(NULL); |
| 1326 renderer_ = NULL; |
1321 } | 1327 } |
1322 | 1328 |
1323 // AudioRenderer::Sink implementation. | 1329 // AudioRenderer::Sink implementation. |
1324 // This method is called on the audio thread. | 1330 // This method is called on the audio thread. |
1325 void OnData(const void* audio_data, | 1331 void OnData(const void* audio_data, |
1326 int bits_per_sample, | 1332 int bits_per_sample, |
1327 int sample_rate, | 1333 int sample_rate, |
1328 int number_of_channels, | 1334 int number_of_channels, |
1329 size_t number_of_frames) override { | 1335 size_t number_of_frames) override { |
1330 voe_audio_transport_->OnData(channel_, | 1336 voe_audio_transport_->OnData(channel_, |
(...skipping 1883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3214 LOG(LS_WARNING) << "Unknown codec " << ToString(codec); | 3220 LOG(LS_WARNING) << "Unknown codec " << ToString(codec); |
3215 return false; | 3221 return false; |
3216 } | 3222 } |
3217 } | 3223 } |
3218 return true; | 3224 return true; |
3219 } | 3225 } |
3220 | 3226 |
3221 } // namespace cricket | 3227 } // namespace cricket |
3222 | 3228 |
3223 #endif // HAVE_WEBRTC_VOICE | 3229 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |