1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://www.xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 #include "ES_Subtitle.h"
22 
23 using namespace TSDemux;
24 
ES_Subtitle(uint16_t pid)25 ES_Subtitle::ES_Subtitle(uint16_t pid)
26  : ElementaryStream(pid)
27 {
28   es_alloc_init = 4000;
29   has_stream_info = true; // doesn't provide stream info
30 }
31 
~ES_Subtitle()32 ES_Subtitle::~ES_Subtitle()
33 {
34 
35 }
36 
Parse(STREAM_PKT * pkt)37 void ES_Subtitle::Parse(STREAM_PKT* pkt)
38 {
39   int l = es_len - es_parsed;
40 
41   if (l > 0)
42   {
43     if (l < 2 || es_buf[0] != 0x20 || es_buf[1] != 0x00)
44     {
45       Reset();
46       return;
47     }
48 
49     if(es_buf[l-1] == 0xff)
50     {
51       pkt->pid          = pid;
52       pkt->data         = es_buf+2;
53       pkt->size         = l-3;
54       pkt->duration     = 0;
55       pkt->dts          = c_dts;
56       pkt->pts          = c_pts;
57       pkt->streamChange = false;
58     }
59 
60     es_parsed = es_consumed = es_len;
61   }
62 }
63