]> git.sesse.net Git - casparcg/blob - server/Channel.cpp
Fixed no_bluefish.
[casparcg] / server / Channel.cpp
1 /*\r
2 * copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
3 *\r
4 *  This file is part of CasparCG.\r
5 *\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
10 *\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
15 \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
18 *\r
19 */\r
20  \r
21 #include "stdAfx.h"\r
22 \r
23 #include "Application.h"\r
24 #include "utils\critsectlock.h"\r
25 #include "Channel.h"\r
26 #include <algorithm>\r
27 \r
28 using namespace std;\r
29 \r
30 namespace caspar {\r
31 \r
32 using namespace caspar::utils;\r
33 \r
34 Channel::Channel(int index, VideoConsumerPtr pConsumer) : pConsumer_(pConsumer), index_(index), monitor_(index)\r
35 {\r
36 }\r
37 \r
38 Channel::~Channel() {\r
39         Destroy();\r
40 }\r
41 \r
42 bool Channel::Initialize() {\r
43         pConsumer_->GetPlaybackControl()->SetMonitor(&monitor_);\r
44         return true;\r
45 }\r
46 \r
47 void Channel::Destroy() {\r
48         pConsumer_.reset();\r
49 }\r
50 \r
51 const TCHAR* Channel::GetFormatDescription() const \r
52 {\r
53         return pConsumer_->GetFormatDescription();\r
54 }\r
55 \r
56 bool Channel::IsPlaybackRunning() const \r
57 {\r
58         return pConsumer_->GetPlaybackControl()->IsRunning();\r
59 }\r
60 \r
61 CG::ICGControl* Channel::GetCGControl() {\r
62         return pConsumer_->GetPlaybackControl()->GetCGControl();\r
63 }\r
64 \r
65 ////////////////\r
66 // LOAD\r
67 bool Channel::Load(MediaProducerPtr pFP, bool loop)\r
68 {\r
69         return pConsumer_->GetPlaybackControl()->Load(pFP, loop);\r
70 }\r
71 \r
72 ////////////////\r
73 // LOADBG\r
74 bool Channel::LoadBackground(MediaProducerPtr pFP, const TransitionInfo& transitionInfo, bool loop)\r
75 {\r
76         return pConsumer_->GetPlaybackControl()->LoadBackground(pFP, transitionInfo, loop);\r
77 }\r
78 \r
79 ////////////////\r
80 // PLAY\r
81 bool Channel::Play()\r
82 {\r
83         return pConsumer_->GetPlaybackControl()->Play();\r
84 }\r
85 \r
86 ////////////////\r
87 // STOP\r
88 bool Channel::Stop(bool block)\r
89 {\r
90         return pConsumer_->GetPlaybackControl()->StopPlayback(block);\r
91 }\r
92 \r
93 bool Channel::SetVideoFormat(const tstring& strDesiredFrameFormat)\r
94 {\r
95         tstring strDesiredFrameFormatUpper = strDesiredFrameFormat;\r
96         tstring strFmtDescUpper = this->pConsumer_->GetFormatDescription();\r
97 \r
98         std::transform(strDesiredFrameFormatUpper.begin(), strDesiredFrameFormatUpper.end(), strDesiredFrameFormatUpper.begin(), toupper);\r
99         std::transform(strFmtDescUpper.begin(), strFmtDescUpper.end(), strFmtDescUpper.begin(), toupper);\r
100 \r
101         if(strDesiredFrameFormatUpper == strFmtDescUpper)\r
102                 return true;\r
103 \r
104         bool stopped = this->Stop(true);        \r
105         bool formatSet = stopped && this->pConsumer_->SetVideoFormat(strDesiredFrameFormat);    \r
106         bool cleared = formatSet && this->Clear();\r
107 \r
108         return stopped && formatSet && cleared;\r
109 }\r
110 \r
111 \r
112 \r
113 bool Channel::Clear() \r
114 {       \r
115         pConsumer_->GetPlaybackControl()->LoadEmpty();\r
116         return true;\r
117 }\r
118 \r
119 bool Channel::Param(const tstring& str) {\r
120         return pConsumer_->GetPlaybackControl()->Param(str);\r
121 }\r
122 \r
123 }       //namespace caspar