diff options
author | dknn <yoann.blein@free.fr> | 2012-06-21 18:06:42 (GMT) |
---|---|---|
committer | dknn <yoann.blein@free.fr> | 2012-09-22 08:53:12 (GMT) |
commit | f374887e7a27831771304a09a74d6cd54f8ef4e4 (patch) | |
tree | 8490553468223483fee7418e420894260a37692c /Swiften/ScreenSharing/VideoEncoder.cpp | |
parent | 931b52184bf37f298f9c967883a3b71c912f834b (diff) | |
download | swift-contrib-f374887e7a27831771304a09a74d6cd54f8ef4e4.zip swift-contrib-f374887e7a27831771304a09a74d6cd54f8ef4e4.tar.bz2 |
Middle part of the outgoing media pipeline
Diffstat (limited to 'Swiften/ScreenSharing/VideoEncoder.cpp')
-rw-r--r-- | Swiften/ScreenSharing/VideoEncoder.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Swiften/ScreenSharing/VideoEncoder.cpp b/Swiften/ScreenSharing/VideoEncoder.cpp new file mode 100644 index 0000000..40d9bef --- /dev/null +++ b/Swiften/ScreenSharing/VideoEncoder.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2012 Yoann Blein + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include <Swiften/ScreenSharing/VideoEncoder.h> + +namespace Swift { + +void VideoEncoder::addFrame(VideoFrame::ref frame) +{ + boost::mutex::scoped_lock lock(queueMutex); + frames.push(frame); + lock.unlock(); + queueCondVar.notify_one(); +} + +void VideoEncoder::startEncoding() +{ + stop = false; + encodingThread = boost::thread(&VideoEncoder::encodingLoop, this); +} + +void VideoEncoder::stopEncoding() +{ + stop = true; + encodingThread.join(); +} + +VideoFrame::ref VideoEncoder::popWhenFrameIsAvailable() +{ + boost::mutex::scoped_lock lock(queueMutex); + while (frames.empty()) { + queueCondVar.wait(lock); + } + VideoFrame::ref popped = frames.front(); + frames.pop(); + return popped; +} + +} |