1/*--------------------------------------------------------------------------
2Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved.
3
4Redistribution and use in source and binary forms, with or without
5modification, are permitted provided that the following conditions are met:
6    * Redistributions of source code must retain the above copyright
7      notice, this list of conditions and the following disclaimer.
8    * Redistributions in binary form must reproduce the above copyright
9      notice, this list of conditions and the following disclaimer in the
10      documentation and/or other materials provided with the distribution.
11    * Neither the name of Code Aurora nor
12      the names of its contributors may be used to endorse or promote
13      products derived from this software without specific prior written
14      permission.
15
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27--------------------------------------------------------------------------*/
28#ifndef __DTSPARSER_H
29#define __DTSPARSER_H
30
31#include "OMX_Core.h"
32#include "OMX_QCOMExtns.h"
33#include "qc_omx_component.h"
34
35#include<stdlib.h>
36
37#include <stdio.h>
38#include <inttypes.h>
39
40#ifdef _ANDROID_
41extern "C"{
42#include<utils/Log.h>
43}
44#else
45#define ALOGE(fmt, args...) fprintf(stderr, fmt, ##args)
46#endif /* _ANDROID_ */
47
48class omx_time_stamp_reorder {
49public:
50	omx_time_stamp_reorder();
51	~omx_time_stamp_reorder();
52	void set_timestamp_reorder_mode(bool flag);
53        void enable_debug_print(bool flag);
54	bool insert_timestamp(OMX_BUFFERHEADERTYPE *header);
55	bool get_next_timestamp(OMX_BUFFERHEADERTYPE *header, bool is_interlaced);
56	bool remove_time_stamp(OMX_TICKS ts, bool is_interlaced);
57	void flush_timestamp();
58
59private:
60	#define TIME_SZ 64
61	typedef struct timestamp {
62		OMX_TICKS timestamps;
63		bool in_use;
64	}timestamp;
65	typedef struct time_stamp_list {
66		timestamp input_timestamps[TIME_SZ];
67		time_stamp_list *next;
68		time_stamp_list *prev;
69		unsigned int entries_filled;
70	}time_stamp_list;
71	bool error;
72	time_stamp_list *phead,*pcurrent;
73	bool get_current_list();
74	bool add_new_list();
75	bool update_head();
76	void delete_list();
77	void handle_error()
78	{
79		ALOGE("Error handler called for TS Parser");
80		if (error)
81			return;
82		error = true;
83		delete_list();
84	}
85	bool reorder_ts;
86        bool print_debug;
87};
88#endif
89