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_CameraBuffer.cpp
20 * @brief This file contains the implementation of the %_CameraBuffer class.
24 #include <FBaseSysLog.h>
25 #include "FMedia_CameraBuffer.h"
27 using namespace Tizen::Base;
28 using namespace Tizen::Graphics;
30 namespace Tizen { namespace Media
33 _CameraBuffer::_CameraBuffer(void)
34 : __bufferType(_CAMERA_BUFFER_NONE)
35 , __pixelFormat(MEDIA_PIXEL_FORMAT_NONE)
43 _CameraBuffer::~_CameraBuffer(void)
48 _CameraBuffer::Construct(int capacity, _CameraBufferType bufferType, MediaPixelFormat pixelFormat, int width, int height)
51 // SysLog(NID_MEDIA, "Enter. capacity:%d, bufferType:%d, pixelFormat:%d, width:%d, height:%d", capacity, bufferType, pixelFormat, width, height);
52 SysTryReturn(NID_MEDIA, capacity>0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The capacity[%d] is invalid.", capacity);
53 SysTryReturn(NID_MEDIA, bufferType >= _CAMERA_BUFFER_PREVIEW && bufferType <= _CAMERA_BUFFER_CAPTURE, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The bufferType(%d) is invalid.", bufferType);
54 SysTryReturn(NID_MEDIA, pixelFormat >= MEDIA_PIXEL_FORMAT_NONE, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The pixelFormat(%d) is invalid.", pixelFormat);
56 r = ByteBuffer::Construct(capacity);
57 SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
59 __bufferType = bufferType;
60 __pixelFormat = pixelFormat;
71 _CameraBuffer::Construct(int capacity, _CameraBufferType bufferType, CodecType codec, bool hasHeader, int width, int height)
74 // SysLog(NID_MEDIA, "Capacity:%d, bufferType:%d, codec:0x%x, width:%d, height:%d", capacity, bufferType, codec, width, height);
75 SysTryReturn(NID_MEDIA, capacity>0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The capacity[%d] is invalid.", capacity);
76 SysTryReturn(NID_MEDIA, bufferType >= _CAMERA_BUFFER_PREVIEW && bufferType <= _CAMERA_BUFFER_CAPTURE, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The bufferType(%d) is invalid.", bufferType);
77 SysTryReturn(NID_MEDIA, codec >= CODEC_NONE && codec < CODEC_MAX
78 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The codec(0x%x) is invalid.", codec);
80 r = ByteBuffer::Construct(capacity);
81 SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
83 __bufferType = bufferType;
87 __hasHeader = hasHeader;
96 _CameraBuffer::Construct(const _CameraBuffer& cameraBuffer)
99 // SysLog(NID_MEDIA, "BufferType:%d, pixelFormat:%d", cameraBuffer.__bufferType, cameraBuffer.__pixelFormat);
101 r = ByteBuffer::Construct(cameraBuffer);
102 SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
104 __bufferType = cameraBuffer.__bufferType;
105 __pixelFormat = cameraBuffer.__pixelFormat;
106 __width = cameraBuffer.__width;
107 __height = cameraBuffer.__height;
108 __codec = cameraBuffer.__codec;
109 __hasHeader = cameraBuffer.__hasHeader;
118 _CameraBuffer::GetPixelFormat(void) const
120 return __pixelFormat;
124 _CameraBuffer::GetBufferType(void) const
130 _CameraBuffer::GetWidth(void) const
136 _CameraBuffer::GetHeight(void) const
142 _CameraBuffer::GetCodecType(void) const