diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-14 04:22:22 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-14 04:22:22 +0000 |
commit | 9d33f85ce5de15425824fe9d7d4074e603cda59c (patch) | |
tree | f4c770a9bf8f27c510979831ea57d6640dbd1728 | |
parent | ed6172c83a0215e445f2b4ec83e8f38e2079d135 (diff) | |
download | chromium_src-9d33f85ce5de15425824fe9d7d4074e603cda59c.zip chromium_src-9d33f85ce5de15425824fe9d7d4074e603cda59c.tar.gz chromium_src-9d33f85ce5de15425824fe9d7d4074e603cda59c.tar.bz2 |
Remove CommandLine dependency from the Linux's AudioCapturer.
Now ChromotingHostContext is used to pass Pipe name to the audio capturer.
BUG=148742
Review URL: https://chromiumcodereview.appspot.com/10911271
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156739 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | remoting/host/audio_capturer_linux.cc | 21 | ||||
-rw-r--r-- | remoting/host/audio_capturer_linux.h | 4 | ||||
-rw-r--r-- | remoting/host/remoting_me2me_host.cc | 27 |
3 files changed, 36 insertions, 16 deletions
diff --git a/remoting/host/audio_capturer_linux.cc b/remoting/host/audio_capturer_linux.cc index 5af0d4c..b4a8fd0 100644 --- a/remoting/host/audio_capturer_linux.cc +++ b/remoting/host/audio_capturer_linux.cc @@ -9,19 +9,18 @@ #include <sys/types.h> #include <unistd.h> -#include "base/command_line.h" #include "base/eintr_wrapper.h" #include "base/file_path.h" +#include "base/lazy_instance.h" #include "base/logging.h" #include "base/stl_util.h" #include "remoting/proto/audio.pb.h" +#include "remoting/host/chromoting_host_context.h" namespace remoting { namespace { -const char kAudioPipeOptionName[] = "audio-pipe-name"; - // PulseAudio's module-pipe-sink must be configured to use the following // parameters for the sink we read from. const AudioPacket_SamplingRate kSamplingRate = AudioPacket::SAMPLING_RATE_44100; @@ -37,6 +36,12 @@ const int kCapturingPeriodMs = 40; #define F_SETPIPE_SZ 1031 #endif // defined(F_SETPIPE_SZ) +// Pipename used to capture audio stream from. +// TODO(sergeyu): Pass this to AudioCapturerLinux constructor once we have +// Linux-specific DesktopEnvironmentFactory +base::LazyInstance<FilePath>::Leaky + g_audio_pipe_name = LAZY_INSTANCE_INITIALIZER; + const int IsPacketOfSilence(const std::string& data) { const int64* int_buf = reinterpret_cast<const int64*>(data.data()); for (size_t i = 0; i < data.size() / sizeof(int64); i++) { @@ -175,14 +180,16 @@ void AudioCapturerLinux::WaitForPipeReadable() { &file_descriptor_watcher_, this); } +void AudioCapturerLinux::SetPipeName(const FilePath& pipe_name) { + g_audio_pipe_name.Get() = pipe_name; +} + bool AudioCapturer::IsSupported() { - CommandLine* cl = CommandLine::ForCurrentProcess(); - return !cl->GetSwitchValuePath(kAudioPipeOptionName).empty(); + return !g_audio_pipe_name.Get().empty(); } scoped_ptr<AudioCapturer> AudioCapturer::Create() { - CommandLine* cl = CommandLine::ForCurrentProcess(); - FilePath path = cl->GetSwitchValuePath(kAudioPipeOptionName); + FilePath path = g_audio_pipe_name.Get(); if (path.empty()) return scoped_ptr<AudioCapturer>(); return scoped_ptr<AudioCapturer>(new AudioCapturerLinux(path)); diff --git a/remoting/host/audio_capturer_linux.h b/remoting/host/audio_capturer_linux.h index c85beb3..8a825ff 100644 --- a/remoting/host/audio_capturer_linux.h +++ b/remoting/host/audio_capturer_linux.h @@ -18,6 +18,10 @@ namespace remoting { class AudioCapturerLinux : public AudioCapturer, public MessageLoopForIO::Watcher { public: + // Must be called to configure the capturer before the first instance is + // created. + static void SetPipeName(const FilePath& pipe_name); + explicit AudioCapturerLinux(const FilePath& pipe_name); virtual ~AudioCapturerLinux(); diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc index 1e518af..d1989db 100644 --- a/remoting/host/remoting_me2me_host.cc +++ b/remoting/host/remoting_me2me_host.cc @@ -68,9 +68,9 @@ #include "remoting/host/curtain_mode_mac.h" #endif // defined(OS_MACOSX) -#if defined(OS_POSIX) -#include <signal.h> -#endif // defined(OS_POSIX) +#if defined(OS_LINUX) +#include "remoting/host/audio_capturer_linux.h" +#endif // defined(OS_LINUX) // N.B. OS_WIN is defined by including src/base headers. #if defined(OS_WIN) @@ -93,6 +93,10 @@ const char kDaemonIpcSwitchName[] = "daemon-pipe"; // The command line switch used to get version of the daemon. const char kVersionSwitchName[] = "version"; +// The command line switch used to pass name of the pipe to capture audio on +// linux. +const char kAudioPipeSwitchName[] = "audio-pipe-name"; + const char kUnofficialOAuth2ClientId[] = "440925447803-2pi3v45bff6tp1rde2f7q6lgbor3o5uj.apps.googleusercontent.com"; const char kUnofficialOAuth2ClientSecret[] = "W2ieEsG-R1gIA4MMurGrgMc_"; @@ -709,8 +713,8 @@ class HostProcess int exit_code_; #if defined(OS_MACOSX) - remoting::CurtainMode curtain_; -#endif + remoting::CurtainMode curtain_; +#endif // defined(OS_MACOSX) }; } // namespace remoting @@ -758,10 +762,6 @@ int main(int argc, char** argv) { // single-threaded. net::EnableSSLServerSockets(); -#if defined(OS_LINUX) - remoting::VideoFrameCapturer::EnableXDamage(true); -#endif - // Create the main message loop and start helper threads. MessageLoop message_loop(MessageLoop::TYPE_UI); base::Closure quit_message_loop = base::Bind(&QuitMessageLoop, &message_loop); @@ -769,6 +769,15 @@ int main(int argc, char** argv) { new remoting::ChromotingHostContext( new remoting::AutoThreadTaskRunner(message_loop.message_loop_proxy(), quit_message_loop))); + +#if defined(OS_LINUX) + // TODO(sergeyu): Pass configuration parameters to the Linux-specific version + // of DesktopEnvironmentFactory when we have it. + remoting::VideoFrameCapturer::EnableXDamage(true); + remoting::AudioCapturerLinux::SetPipeName(CommandLine::ForCurrentProcess()-> + GetSwitchValuePath(kAudioPipeSwitchName)); +#endif // defined(OS_LINUX) + if (!context->Start()) return remoting::kHostInitializationFailed; |