2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FMedia_VideoStreamCoordinator.cpp
20 * @brief This file contains the video stream processing.
23 #include <unique_ptr.h>
24 #include <FBaseSysLog.h>
25 #include <FMediaVideoFrame.h>
26 #include "FMedia_VideoFrameImpl.h"
27 #include "FMedia_VideoStreamCoordinator.h"
29 using namespace Tizen::Base;
30 using namespace Tizen::Base::Collection;
32 namespace Tizen { namespace Media
35 _VideoStreamCoordinator::_VideoStreamCoordinator(void)
36 : __pStreamFilterList(null, _ListPtrUtil::remover)
41 _VideoStreamCoordinator::~_VideoStreamCoordinator(void)
47 _VideoStreamCoordinator::Construct(void)
51 __pStreamFilterList.reset(new (std::nothrow) ArrayListT<IVideoStreamFilter*>);
52 SysTryReturn(NID_MEDIA, __pStreamFilterList.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
54 r = __pStreamFilterList->Construct();
55 SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
61 _VideoStreamCoordinator::ProcessVideoStreamData(MediaPixelFormat format, int width, int height, int planeCount, byte* data[], int size[], VideoPlaneType planeType[])
65 VideoFrame videoFrame;
66 r = videoFrame.Construct();
67 SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating", GetErrorMessage(r));
69 _VideoFrameImpl* pVideoFrameImpl = _VideoFrameImpl::GetInstance(&videoFrame);
70 SysTryReturn(NID_MEDIA, pVideoFrameImpl != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The implementation object is not found.");
72 r = pVideoFrameImpl->Initialize(format, width, height, planeCount, data, size, planeType);
73 SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating", GetErrorMessage(r));
75 std::unique_ptr <IEnumeratorT<IVideoStreamFilter*> > pEnum (__pStreamFilterList->GetEnumeratorN());
76 SysTryReturn(NID_MEDIA, pEnum.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
78 while (pEnum->MoveNext() == E_SUCCESS)
80 IVideoStreamFilter* pFilter = null;
81 r = pEnum->GetCurrent(pFilter);
82 SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating", GetErrorMessage(r));
84 pFilter->ProcessVideoStream(videoFrame);
91 _VideoStreamCoordinator::AddVideoStreamFilter(IVideoStreamFilter& filter)
93 SysTryReturn(NID_MEDIA, __pStreamFilterList->Contains(&filter) != true, E_OBJ_ALREADY_EXIST, E_OBJ_ALREADY_EXIST, "[E_OBJ_ALREADY_EXIST] The filter already exists.");
96 r = __pStreamFilterList->Add(&filter);
97 SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating", GetErrorMessage(r));
103 _VideoStreamCoordinator::RemoveVideoStreamFilter(IVideoStreamFilter& filter)
105 result r = E_SUCCESS;
107 r = __pStreamFilterList->Remove(&filter);
108 SysTryReturn(NID_MEDIA, r== E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
114 _VideoStreamCoordinator::GetFilterListCount(void) const
116 return __pStreamFilterList->GetCount();