Remove Soundclip handling from libjingle.
BUG= R=pthatcher@webrtc.org Review URL: https://webrtc-codereview.appspot.com/51009004 Cr-Commit-Position: refs/heads/master@{#9216}
This commit is contained in:
@@ -41,7 +41,6 @@
|
||||
#ifdef HAVE_SCTP
|
||||
#include "talk/media/sctp/sctpdataengine.h"
|
||||
#endif
|
||||
#include "talk/session/media/soundclip.h"
|
||||
#include "talk/session/media/srtpfilter.h"
|
||||
#include "webrtc/base/bind.h"
|
||||
#include "webrtc/base/common.h"
|
||||
@@ -311,9 +310,6 @@ void ChannelManager::Terminate_w() {
|
||||
while (!voice_channels_.empty()) {
|
||||
DestroyVoiceChannel_w(voice_channels_.back(), nullptr);
|
||||
}
|
||||
while (!soundclips_.empty()) {
|
||||
DestroySoundclip_w(soundclips_.back());
|
||||
}
|
||||
if (!SetCaptureDevice_w(NULL)) {
|
||||
LOG(LS_WARNING) << "failed to delete video capturer";
|
||||
}
|
||||
@@ -504,45 +500,6 @@ void ChannelManager::DestroyDataChannel_w(DataChannel* data_channel) {
|
||||
delete data_channel;
|
||||
}
|
||||
|
||||
Soundclip* ChannelManager::CreateSoundclip() {
|
||||
return worker_thread_->Invoke<Soundclip*>(
|
||||
Bind(&ChannelManager::CreateSoundclip_w, this));
|
||||
}
|
||||
|
||||
Soundclip* ChannelManager::CreateSoundclip_w() {
|
||||
ASSERT(initialized_);
|
||||
ASSERT(worker_thread_ == rtc::Thread::Current());
|
||||
|
||||
SoundclipMedia* soundclip_media = media_engine_->CreateSoundclip();
|
||||
if (!soundclip_media) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Soundclip* soundclip = new Soundclip(worker_thread_, soundclip_media);
|
||||
soundclips_.push_back(soundclip);
|
||||
return soundclip;
|
||||
}
|
||||
|
||||
void ChannelManager::DestroySoundclip(Soundclip* soundclip) {
|
||||
if (soundclip) {
|
||||
worker_thread_->Invoke<void>(
|
||||
Bind(&ChannelManager::DestroySoundclip_w, this, soundclip));
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelManager::DestroySoundclip_w(Soundclip* soundclip) {
|
||||
// Destroy soundclip.
|
||||
ASSERT(initialized_);
|
||||
Soundclips::iterator it = std::find(soundclips_.begin(),
|
||||
soundclips_.end(), soundclip);
|
||||
ASSERT(it != soundclips_.end());
|
||||
if (it == soundclips_.end())
|
||||
return;
|
||||
|
||||
soundclips_.erase(it);
|
||||
delete soundclip;
|
||||
}
|
||||
|
||||
bool ChannelManager::GetAudioOptions(std::string* in_name,
|
||||
std::string* out_name,
|
||||
AudioOptions* options) {
|
||||
|
||||
@@ -44,7 +44,6 @@ namespace cricket {
|
||||
|
||||
const int kDefaultAudioDelayOffset = 0;
|
||||
|
||||
class Soundclip;
|
||||
class VideoProcessor;
|
||||
class VoiceChannel;
|
||||
class VoiceProcessor;
|
||||
@@ -129,15 +128,9 @@ class ChannelManager : public rtc::MessageHandler,
|
||||
// Destroys a data channel created with the Create API.
|
||||
void DestroyDataChannel(DataChannel* data_channel);
|
||||
|
||||
// Creates a soundclip.
|
||||
Soundclip* CreateSoundclip();
|
||||
// Destroys a soundclip created with the Create API.
|
||||
void DestroySoundclip(Soundclip* soundclip);
|
||||
|
||||
// Indicates whether any channels exist.
|
||||
bool has_channels() const {
|
||||
return (!voice_channels_.empty() || !video_channels_.empty() ||
|
||||
!soundclips_.empty());
|
||||
return (!voice_channels_.empty() || !video_channels_.empty());
|
||||
}
|
||||
|
||||
// Configures the audio and video devices. A null pointer can be passed to
|
||||
@@ -253,7 +246,6 @@ class ChannelManager : public rtc::MessageHandler,
|
||||
typedef std::vector<VoiceChannel*> VoiceChannels;
|
||||
typedef std::vector<VideoChannel*> VideoChannels;
|
||||
typedef std::vector<DataChannel*> DataChannels;
|
||||
typedef std::vector<Soundclip*> Soundclips;
|
||||
|
||||
void Construct(MediaEngineInterface* me,
|
||||
DataEngineInterface* dme,
|
||||
@@ -277,8 +269,6 @@ class ChannelManager : public rtc::MessageHandler,
|
||||
BaseSession* session, const std::string& content_name,
|
||||
bool rtcp, DataChannelType data_channel_type);
|
||||
void DestroyDataChannel_w(DataChannel* data_channel);
|
||||
Soundclip* CreateSoundclip_w();
|
||||
void DestroySoundclip_w(Soundclip* soundclip);
|
||||
bool SetAudioOptions_w(const AudioOptions& options, int delay_offset,
|
||||
const Device* in_dev, const Device* out_dev);
|
||||
bool SetEngineAudioOptions_w(const AudioOptions& options);
|
||||
@@ -306,7 +296,6 @@ class ChannelManager : public rtc::MessageHandler,
|
||||
VoiceChannels voice_channels_;
|
||||
VideoChannels video_channels_;
|
||||
DataChannels data_channels_;
|
||||
Soundclips soundclips_;
|
||||
|
||||
std::string audio_in_device_;
|
||||
std::string audio_out_device_;
|
||||
|
||||
@@ -1,82 +1 @@
|
||||
/*
|
||||
* libjingle
|
||||
* Copyright 2004 Google Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "talk/session/media/soundclip.h"
|
||||
|
||||
namespace cricket {
|
||||
|
||||
enum {
|
||||
MSG_PLAYSOUND = 1,
|
||||
};
|
||||
|
||||
struct PlaySoundMessageData : rtc::MessageData {
|
||||
PlaySoundMessageData(const void *c,
|
||||
int l,
|
||||
SoundclipMedia::SoundclipFlags f)
|
||||
: clip(c),
|
||||
len(l),
|
||||
flags(f),
|
||||
result(false) {
|
||||
}
|
||||
|
||||
const void *clip;
|
||||
int len;
|
||||
SoundclipMedia::SoundclipFlags flags;
|
||||
bool result;
|
||||
};
|
||||
|
||||
Soundclip::Soundclip(rtc::Thread *thread, SoundclipMedia *soundclip_media)
|
||||
: worker_thread_(thread),
|
||||
soundclip_media_(soundclip_media) {
|
||||
}
|
||||
|
||||
bool Soundclip::PlaySound(const void *clip,
|
||||
int len,
|
||||
SoundclipMedia::SoundclipFlags flags) {
|
||||
PlaySoundMessageData data(clip, len, flags);
|
||||
worker_thread_->Send(this, MSG_PLAYSOUND, &data);
|
||||
return data.result;
|
||||
}
|
||||
|
||||
bool Soundclip::PlaySound_w(const void *clip,
|
||||
int len,
|
||||
SoundclipMedia::SoundclipFlags flags) {
|
||||
return soundclip_media_->PlaySound(static_cast<const char *>(clip),
|
||||
len,
|
||||
flags);
|
||||
}
|
||||
|
||||
void Soundclip::OnMessage(rtc::Message *message) {
|
||||
ASSERT(message->message_id == MSG_PLAYSOUND);
|
||||
PlaySoundMessageData *data =
|
||||
static_cast<PlaySoundMessageData *>(message->pdata);
|
||||
data->result = PlaySound_w(data->clip,
|
||||
data->len,
|
||||
data->flags);
|
||||
}
|
||||
|
||||
} // namespace cricket
|
||||
// TODO(solenberg): Remove this file when it's no longer built in Chromium.
|
||||
|
||||
@@ -1,70 +1,2 @@
|
||||
/*
|
||||
* libjingle
|
||||
* Copyright 2004 Google Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
// TODO(solenberg): Remove this file when it's no longer built in Chromium.
|
||||
|
||||
#ifndef TALK_SESSION_MEDIA_SOUNDCLIP_H_
|
||||
#define TALK_SESSION_MEDIA_SOUNDCLIP_H_
|
||||
|
||||
#include "talk/media/base/mediaengine.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
class Thread;
|
||||
|
||||
}
|
||||
|
||||
namespace cricket {
|
||||
|
||||
// Soundclip wraps SoundclipMedia to support marshalling calls to the proper
|
||||
// thread.
|
||||
class Soundclip : private rtc::MessageHandler {
|
||||
public:
|
||||
Soundclip(rtc::Thread* thread, SoundclipMedia* soundclip_media);
|
||||
|
||||
// Plays a sound out to the speakers with the given audio stream. The stream
|
||||
// must be 16-bit little-endian 16 kHz PCM. If a stream is already playing
|
||||
// on this Soundclip, it is stopped. If clip is NULL, nothing is played.
|
||||
// Returns whether it was successful.
|
||||
bool PlaySound(const void* clip,
|
||||
int len,
|
||||
SoundclipMedia::SoundclipFlags flags);
|
||||
|
||||
private:
|
||||
bool PlaySound_w(const void* clip,
|
||||
int len,
|
||||
SoundclipMedia::SoundclipFlags flags);
|
||||
|
||||
// From MessageHandler
|
||||
virtual void OnMessage(rtc::Message* message);
|
||||
|
||||
rtc::Thread* worker_thread_;
|
||||
rtc::scoped_ptr<SoundclipMedia> soundclip_media_;
|
||||
};
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
#endif // TALK_SESSION_MEDIA_SOUNDCLIP_H_
|
||||
|
||||
Reference in New Issue
Block a user