| 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 1312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1323 // callback. | 1323 // callback. |
| 1324 // This method is called on the libjingle worker thread. | 1324 // This method is called on the libjingle worker thread. |
| 1325 // TODO(xians): Make sure Start() is called only once. | 1325 // TODO(xians): Make sure Start() is called only once. |
| 1326 void Start(AudioRenderer* renderer) { | 1326 void Start(AudioRenderer* renderer) { |
| 1327 rtc::CritScope lock(&lock_); | 1327 rtc::CritScope lock(&lock_); |
| 1328 RTC_DCHECK(renderer != NULL); | 1328 RTC_DCHECK(renderer != NULL); |
| 1329 if (renderer_ != NULL) { | 1329 if (renderer_ != NULL) { |
| 1330 RTC_DCHECK(renderer_ == renderer); | 1330 RTC_DCHECK(renderer_ == renderer); |
| 1331 return; | 1331 return; |
| 1332 } | 1332 } |
| 1333 | |
| 1334 // TODO(xians): Remove AddChannel() call after Chrome turns on APM | |
| 1335 // in getUserMedia by default. | |
| 1336 renderer->AddChannel(channel_); | |
| 1337 renderer->SetSink(this); | 1333 renderer->SetSink(this); |
| 1338 renderer_ = renderer; | 1334 renderer_ = renderer; |
| 1339 } | 1335 } |
| 1340 | 1336 |
| 1341 // Stops rendering by setting the sink of the renderer to NULL. No data | 1337 // Stops rendering by setting the sink of the renderer to NULL. No data |
| 1342 // callback will be received after this method. | 1338 // callback will be received after this method. |
| 1343 // This method is called on the libjingle worker thread. | 1339 // This method is called on the libjingle worker thread. |
| 1344 void Stop() { | 1340 void Stop() { |
| 1345 rtc::CritScope lock(&lock_); | 1341 rtc::CritScope lock(&lock_); |
| 1346 if (renderer_ == NULL) | 1342 if (renderer_ != NULL) { |
| 1347 return; | 1343 renderer_->SetSink(NULL); |
| 1348 | 1344 renderer_ = NULL; |
| 1349 renderer_->RemoveChannel(channel_); | 1345 } |
| 1350 renderer_->SetSink(NULL); | |
| 1351 renderer_ = NULL; | |
| 1352 } | 1346 } |
| 1353 | 1347 |
| 1354 // AudioRenderer::Sink implementation. | 1348 // AudioRenderer::Sink implementation. |
| 1355 // This method is called on the audio thread. | 1349 // This method is called on the audio thread. |
| 1356 void OnData(const void* audio_data, | 1350 void OnData(const void* audio_data, |
| 1357 int bits_per_sample, | 1351 int bits_per_sample, |
| 1358 int sample_rate, | 1352 int sample_rate, |
| 1359 int number_of_channels, | 1353 int number_of_channels, |
| 1360 size_t number_of_frames) override { | 1354 size_t number_of_frames) override { |
| 1361 voe_audio_transport_->OnData(channel_, | 1355 voe_audio_transport_->OnData(channel_, |
| (...skipping 1822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3184 LOG(LS_WARNING) << "Unknown codec " << ToString(codec); | 3178 LOG(LS_WARNING) << "Unknown codec " << ToString(codec); |
| 3185 return false; | 3179 return false; |
| 3186 } | 3180 } |
| 3187 } | 3181 } |
| 3188 return true; | 3182 return true; |
| 3189 } | 3183 } |
| 3190 | 3184 |
| 3191 } // namespace cricket | 3185 } // namespace cricket |
| 3192 | 3186 |
| 3193 #endif // HAVE_WEBRTC_VOICE | 3187 #endif // HAVE_WEBRTC_VOICE |
| OLD | NEW |