[content] Fix null check codes
[platform/framework/native/content.git] / src / FCntVideoMetadata.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17 /**
18  * @file                FCntVideoMetadata.cpp
19  * @brief               This is the implementation file for the %VideoMetadata class.
20  *
21  * This file contains implementation of the %VideoMetadata class.
22  */
23
24 #include <FBaseSysLog.h>
25 #include <FCntVideoMetadata.h>
26 #include <FCnt_VideoMetadataImpl.h>
27
28 using namespace Tizen::Base;
29 using namespace Tizen::Graphics;
30
31 namespace Tizen { namespace Content
32 {
33
34 VideoMetadata::VideoMetadata(void)
35         : Object()
36         , __pImpl(new (std::nothrow) _VideoMetadataImpl())
37 {
38
39 }
40
41 VideoMetadata::~VideoMetadata(void)
42 {
43         if (__pImpl != null)
44         {
45                 delete __pImpl;
46                 __pImpl = null;
47         }
48 }
49
50 VideoMetadata::VideoMetadata(const VideoMetadata& rhs)
51         : Tizen::Base::Object()
52         , __pImpl(new (std::nothrow) _VideoMetadataImpl(*rhs.__pImpl))
53 {
54
55 }
56
57 VideoMetadata&
58 VideoMetadata::operator =(const VideoMetadata& rhs)
59 {
60         // check for self-assignment
61         if (this == &rhs)
62         {
63                 return *this;
64         }
65
66         *__pImpl = *rhs.__pImpl;
67
68         return *this;
69 }
70
71 int
72 VideoMetadata::GetHashCode(void) const
73 {
74         return __pImpl->GetHashCode();
75 }
76
77 bool
78 VideoMetadata::Equals(const Object& rhs) const
79 {
80         const VideoMetadata* pRhs = dynamic_cast <const VideoMetadata*>(&rhs);
81         if (pRhs == null)
82         {
83                 return false;
84         }
85
86         return __pImpl->Equals(*pRhs->__pImpl);
87 }
88
89 int
90 VideoMetadata::GetWidth(void) const
91 {
92         if (__pImpl == null)
93         {
94                 return 0;
95         }
96         return __pImpl->GetWidth();
97 }
98
99 int
100 VideoMetadata::GetHeight(void) const
101 {
102         if (__pImpl == null)
103         {
104                 return 0;
105         }
106         return __pImpl->GetHeight();
107 }
108
109 long
110 VideoMetadata::GetDuration(void) const
111 {
112         if (__pImpl == null)
113         {
114                 return 0;
115         }
116         return __pImpl->GetDuration();
117 }
118
119 int
120 VideoMetadata::GetFramerate(void) const
121 {
122         if (__pImpl == null)
123         {
124                 return 0;
125         }
126         return __pImpl->GetFramerate();
127 }
128
129 int
130 VideoMetadata::GetBitrate(void) const
131 {
132         if (__pImpl == null)
133         {
134                 return 0;
135         }
136         return __pImpl->GetAudioBitrate();
137 }
138
139 int
140 VideoMetadata::GetAudioBitrate(void) const
141 {
142         if (__pImpl == null)
143         {
144                 return 0;
145         }
146         return __pImpl->GetAudioBitrate();
147 }
148
149 int
150 VideoMetadata::GetVideoBitrate(void) const
151 {
152         if (__pImpl == null)
153         {
154                 return 0;
155         }
156         return __pImpl->GetVideoBitrate();
157 }
158
159 String
160 VideoMetadata::GetGenre(void) const
161 {
162         if (__pImpl == null)
163         {
164                 return String();
165         }
166         return __pImpl->GetGenre();
167 }
168
169 String
170 VideoMetadata::GetComment(void) const
171 {
172         if (__pImpl == null)
173         {
174                 return String();
175         }
176         return __pImpl->GetComment();
177 }
178
179 String
180 VideoMetadata::GetDescription(void) const
181 {
182         if (__pImpl == null)
183         {
184                 return String();
185         }
186         return __pImpl->GetDescription();
187 }
188
189 Bitmap*
190 VideoMetadata::GetAlbumArtN(void) const
191 {
192         ClearLastResult();
193         result r = E_SUCCESS;
194
195         Bitmap* pBitmap = null;
196         SysTryReturn(NID_CNT, __pImpl != null, null, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] GetAlbumArtN failed.");
197
198         pBitmap = __pImpl->GetAlbumArtN();
199         r = GetLastResult();
200         SysTryReturn(NID_CNT, pBitmap != null, null, r, "[%s] GetAlbumArtN failed.", GetErrorMessage(r));
201
202         return pBitmap;
203 }
204 }}