1 /*-------------------------------------------------------------------------- 2 Copyright (c) 2010-2015, The Linux Foundation. All rights reserved. 3 4 Redistribution and use in source and binary forms, with or without 5 modification, 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 The Linux Foundation 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 16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 ADVISED 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 #include <pthread.h> 40 41 #ifdef _ANDROID_ 42 extern "C" { 43 #include<utils/Log.h> 44 } 45 #else 46 #define ALOGE(fmt, args...) fprintf(stderr, fmt, ##args) 47 #endif /* _ANDROID_ */ 48 49 class omx_time_stamp_reorder 50 { 51 class auto_lock { 52 public: 53 auto_lock(pthread_mutex_t *lock) 54 : mLock(lock) { 55 if (mLock) 56 pthread_mutex_lock(mLock); 57 } 58 ~auto_lock() { 59 if (mLock) 60 pthread_mutex_unlock(mLock); 61 } 62 private: 63 pthread_mutex_t *mLock; 64 }; 65 66 public: 67 omx_time_stamp_reorder(); 68 ~omx_time_stamp_reorder(); 69 void set_timestamp_reorder_mode(bool flag); 70 void enable_debug_print(bool flag); 71 bool insert_timestamp(OMX_BUFFERHEADERTYPE *header); 72 bool get_next_timestamp(OMX_BUFFERHEADERTYPE *header, bool is_interlaced); 73 bool remove_time_stamp(OMX_TICKS ts, bool is_interlaced); 74 void flush_timestamp(); 75 76 private: 77 #define TIME_SZ 64 78 typedef struct timestamp { 79 OMX_TICKS timestamps; 80 bool in_use; 81 } timestamp; 82 typedef struct time_stamp_list { 83 timestamp input_timestamps[TIME_SZ]; 84 time_stamp_list *next; 85 time_stamp_list *prev; 86 unsigned int entries_filled; 87 } time_stamp_list; 88 bool error; 89 time_stamp_list *phead,*pcurrent; 90 bool get_current_list(); 91 bool add_new_list(); 92 bool update_head(); 93 void delete_list(); 94 void handle_error() { 95 ALOGE("Error handler called for TS Parser"); 96 97 if (error) 98 return; 99 100 error = true; 101 delete_list(); 102 } 103 bool reorder_ts; 104 bool print_debug; 105 pthread_mutex_t m_lock; 106 }; 107 #endif 108