summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Kaiser <wireshark@kaiser.cx>2015-11-23 21:49:03 +0800
committerMartin Kaiser <wireshark@kaiser.cx>2015-11-28 09:45:29 +0000
commit68c9cc0419dcb69b54378a95fe5c76214a888882 (patch)
treed25cb22df53e64132bc66ae12dff3e6cdd884e4b
parent18a08f434fce4bde56b3a8621dfc05c4dcf06df2 (diff)
downloadwireshark-68c9cc0419dcb69b54378a95fe5c76214a888882.tar.gz
[mp2t] use the correct file infomation for PCR detection
when we check for an mpeg2 transport stream, we're trying to detect an initial offset before the first sync byte and the length of additional data appended to each packet use those values when we go through the file again and verify the PCR Bug: 11749 Change-Id: Iab03cb271d23d38f850ca857b64ca47ba4501175 Reviewed-on: https://code.wireshark.org/review/12183 Reviewed-by: Michael Mann <mmann78@netscape.net> (cherry picked from commit 6da516821d24b8857fe3a55703e517db0106d23c) Reviewed-on: https://code.wireshark.org/review/12244 Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
-rw-r--r--wiretap/mp2t.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/wiretap/mp2t.c b/wiretap/mp2t.c
index ba626ed677..0a432d7031 100644
--- a/wiretap/mp2t.c
+++ b/wiretap/mp2t.c
@@ -165,7 +165,8 @@ mp2t_read_pcr(guint8 *buffer)
* potentially scanning the entire file for a PCR?
*/
static gboolean
-mp2t_find_next_pcr(wtap *wth, int *err, gchar **err_info, guint32 *idx, guint64 *pcr, guint16 *pid)
+mp2t_find_next_pcr(wtap *wth, guint8 trailer_len,
+ int *err, gchar **err_info, guint32 *idx, guint64 *pcr, guint16 *pid)
{
guint8 buffer[MP2T_SIZE];
gboolean found;
@@ -174,7 +175,8 @@ mp2t_find_next_pcr(wtap *wth, int *err, gchar **err_info, guint32 *idx, guint64
found = FALSE;
while (FALSE == found) {
(*idx)++;
- if (!wtap_read_bytes_or_eof(wth->fh, buffer, MP2T_SIZE, err, err_info)) {
+ if (!wtap_read_bytes_or_eof(
+ wth->fh, buffer, MP2T_SIZE+trailer_len, err, err_info)) {
/* Read error, short read, or EOF */
return FALSE;
}
@@ -209,7 +211,8 @@ mp2t_find_next_pcr(wtap *wth, int *err, gchar **err_info, guint32 *idx, guint64
}
static wtap_open_return_val
-mp2t_bits_per_second(wtap *wth, guint64 *bitrate, int *err, gchar **err_info)
+mp2t_bits_per_second(wtap *wth, gint first, guint8 trailer_len,
+ guint64 *bitrate, int *err, gchar **err_info)
{
guint32 pn1, pn2;
guint64 pcr1, pcr2;
@@ -226,9 +229,11 @@ mp2t_bits_per_second(wtap *wth, guint64 *bitrate, int *err, gchar **err_info)
* to the time scale of the underlying transport stream?
*/
- idx = 0;
+ if (first<0)
+ return WTAP_OPEN_ERROR;
+ idx = (guint32)first;
- if (!mp2t_find_next_pcr(wth, err, err_info, &idx, &pcr1, &pid1)) {
+ if (!mp2t_find_next_pcr(wth, trailer_len, err, err_info, &idx, &pcr1, &pid1)) {
/* Read error, short read, or EOF */
if (*err == WTAP_ERR_SHORT_READ)
return WTAP_OPEN_NOT_MINE; /* not a full frame */
@@ -246,7 +251,7 @@ mp2t_bits_per_second(wtap *wth, guint64 *bitrate, int *err, gchar **err_info)
pn2 = pn1;
while (pn1 == pn2) {
- if (!mp2t_find_next_pcr(wth, err, err_info, &idx, &pcr2, &pid2)) {
+ if (!mp2t_find_next_pcr(wth, trailer_len, err, err_info, &idx, &pcr2, &pid2)) {
/* Read error, short read, or EOF */
if (*err == WTAP_ERR_SHORT_READ)
return WTAP_OPEN_NOT_MINE; /* not a full frame */
@@ -355,7 +360,8 @@ mp2t_open(wtap *wth, int *err, gchar **err_info)
}
/* Ensure there is a valid bitrate */
- status = mp2t_bits_per_second(wth, &bitrate, err, err_info);
+ status = mp2t_bits_per_second(wth, first, trailer_len,
+ &bitrate, err, err_info);
if (status != WTAP_OPEN_MINE) {
return status;
}