2 * copyright (c) 2010 Sveriges Television AB <info@casparcg.com>
\r
4 * This file is part of CasparCG.
\r
6 * CasparCG is free software: you can redistribute it and/or modify
\r
7 * it under the terms of the GNU General Public License as published by
\r
8 * the Free Software Foundation, either version 3 of the License, or
\r
9 * (at your option) any later version.
\r
11 * CasparCG is distributed in the hope that it will be useful,
\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 * GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License
\r
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
\r
23 #include "Application.h"
\r
24 #include "utils\critsectlock.h"
\r
25 #include "Channel.h"
\r
26 #include <algorithm>
\r
28 using namespace std;
\r
32 using namespace caspar::utils;
\r
34 Channel::Channel(int index, VideoConsumerPtr pConsumer) : pConsumer_(pConsumer), index_(index), monitor_(index)
\r
38 Channel::~Channel() {
\r
42 bool Channel::Initialize() {
\r
43 pConsumer_->GetPlaybackControl()->SetMonitor(&monitor_);
\r
47 void Channel::Destroy() {
\r
51 const TCHAR* Channel::GetFormatDescription() const
\r
53 return pConsumer_->GetFormatDescription();
\r
56 bool Channel::IsPlaybackRunning() const
\r
58 return pConsumer_->GetPlaybackControl()->IsRunning();
\r
61 CG::ICGControl* Channel::GetCGControl() {
\r
62 return pConsumer_->GetPlaybackControl()->GetCGControl();
\r
67 bool Channel::Load(MediaProducerPtr pFP, bool loop)
\r
69 return pConsumer_->GetPlaybackControl()->Load(pFP, loop);
\r
74 bool Channel::LoadBackground(MediaProducerPtr pFP, const TransitionInfo& transitionInfo, bool loop)
\r
76 return pConsumer_->GetPlaybackControl()->LoadBackground(pFP, transitionInfo, loop);
\r
81 bool Channel::Play()
\r
83 return pConsumer_->GetPlaybackControl()->Play();
\r
88 bool Channel::Stop(bool block)
\r
90 return pConsumer_->GetPlaybackControl()->StopPlayback(block);
\r
93 bool Channel::SetVideoFormat(const tstring& strDesiredFrameFormat)
\r
95 tstring strDesiredFrameFormatUpper = strDesiredFrameFormat;
\r
96 tstring strFmtDescUpper = this->pConsumer_->GetFormatDescription();
\r
98 std::transform(strDesiredFrameFormatUpper.begin(), strDesiredFrameFormatUpper.end(), strDesiredFrameFormatUpper.begin(), toupper);
\r
99 std::transform(strFmtDescUpper.begin(), strFmtDescUpper.end(), strFmtDescUpper.begin(), toupper);
\r
101 if(strDesiredFrameFormatUpper == strFmtDescUpper)
\r
104 bool stopped = this->Stop(true);
\r
105 bool formatSet = stopped && this->pConsumer_->SetVideoFormat(strDesiredFrameFormat);
\r
106 bool cleared = formatSet && this->Clear();
\r
108 return stopped && formatSet && cleared;
\r
113 bool Channel::Clear()
\r
115 pConsumer_->GetPlaybackControl()->LoadEmpty();
\r
119 bool Channel::Param(const tstring& str) {
\r
120 return pConsumer_->GetPlaybackControl()->Param(str);
\r