1/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18#ifndef VIDEO_BROWSER_INTERNAL_H
19#define VIDEO_BROWSER_INTERNAL_H
20
21#include "VideoBrowserMain.h"
22
23#include "M4READER_Common.h"
24#include "M4DECODER_Common.h"
25
26
27#define VIDEO_BROWSER_BGR565
28
29/*---------------------------- MACROS ----------------------------*/
30#define CHECK_PTR(fct, p, err, errValue) \
31{ \
32    if (M4OSA_NULL == p) \
33    { \
34        err = errValue ; \
35        M4OSA_TRACE1_1("" #fct "(L%d): " #p " is NULL, returning " #errValue "", __LINE__) ; \
36        goto fct##_cleanUp; \
37    } \
38}
39
40#define CHECK_ERR(fct, err) \
41{ \
42    if (M4OSA_ERR_IS_ERROR(err)) \
43    { \
44        M4OSA_TRACE1_2("" #fct "(L%d): ERROR 0x%.8x returned", __LINE__,err) ; \
45        goto fct##_cleanUp; \
46    } \
47    else if (M4OSA_ERR_IS_WARNING(err)) \
48    { \
49        M4OSA_TRACE2_2("" #fct "(L%d): WARNING 0x%.8x returned", __LINE__,err) ; \
50    } \
51}
52
53#define CHECK_STATE(fct, state, pC) \
54{ \
55    if (state != pC->m_state) \
56    { \
57        M4OSA_TRACE1_1("" #fct " called in bad state %d", pC->m_state) ; \
58        err = M4ERR_STATE ; \
59        goto fct##_cleanUp; \
60    } \
61}
62
63#define SAFE_FREE(p) \
64{ \
65    if (M4OSA_NULL != p) \
66    { \
67        free(p) ; \
68        p = M4OSA_NULL ; \
69    } \
70}
71
72/*--- Video Browser state ---*/
73typedef enum
74{
75    VideoBrowser_kVBCreating,
76    VideoBrowser_kVBOpened,
77    VideoBrowser_kVBBrowsing
78} VideoBrowser_videoBrowerState;
79
80
81/*--- Video Browser execution context. ---*/
82typedef struct
83{
84    VideoBrowser_videoBrowerState       m_state ;
85    VideoBrowser_videoBrowerDrawMode    m_drawmode;
86
87    M4OSA_Context                       g_hbmp2;
88    M4OSA_Context                       dc;
89    M4OSA_Int16*                        g_bmPixels2;
90
91    /*--- Reader parameters ---*/
92    M4OSA_FileReadPointer               m_fileReadPtr;
93    M4READER_GlobalInterface*           m_3gpReader ;
94    M4READER_DataInterface*             m_3gpData ;
95    M4READER_MediaType                  m_mediaType ;
96    M4OSA_Context                       m_pReaderCtx ;
97
98    M4_StreamHandler*                   m_pStreamHandler ;
99    M4_AccessUnit                       m_accessUnit ;
100
101    /*--- Decoder parameters ---*/
102    M4DECODER_VideoInterface*           m_pDecoder ;
103    M4OSA_Context                       m_pDecoderCtx ;
104
105    /*--- Common display parameters ---*/
106    M4OSA_UInt32                        m_x ;
107    M4OSA_UInt32                        m_y ;
108    M4VIFI_ImagePlane                   m_outputPlane[3] ;
109
110    /*--- Current browsing time ---*/
111    M4OSA_UInt32                        m_currentCTS ;
112
113    /*--- Platform dependent display parameters ---*/
114    M4OSA_Context                       m_pCoreContext ;
115
116    /*--- Callback function settings ---*/
117    videoBrowser_Callback               m_pfCallback;
118    M4OSA_Void*                         m_pCallbackUserData;
119
120    /*--- Codec Loader core context ---*/
121    M4OSA_Context                       m_pCodecLoaderContext;
122
123    /*--- Required color type ---*/
124    VideoBrowser_VideoColorType         m_frameColorType;
125
126} VideoBrowserContext;
127
128#endif /* VIDEO_BROWSER_INTERNAL_H */
129