|
@@ -1,6 +1,7 @@
|
|
|
#include "stdafx.h"
|
|
|
#include "mp4info.h"
|
|
|
|
|
|
+
|
|
|
static unsigned int big_to_small_endian_32bit(unsigned int const big)
|
|
|
{
|
|
|
unsigned int data = big;
|
|
@@ -12,6 +13,7 @@ static unsigned int big_to_small_endian_32bit(unsigned int const big)
|
|
|
return uret;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
static __int64 big_to_small_endian_64bit(__int64 const big)
|
|
|
{
|
|
|
__int64 data = big;
|
|
@@ -29,7 +31,7 @@ static __int64 big_to_small_endian_64bit(__int64 const big)
|
|
|
|
|
|
|
|
|
//ftyp, free, mdat box not encryt
|
|
|
-unsigned int get_noencrypt_boxs_size(const char* pfilename)
|
|
|
+unsigned int get_noencrypt_boxs_size(const char* pfilename, const filecryption_callback_t* pcallback)
|
|
|
{
|
|
|
unsigned int uret = 0;
|
|
|
if (NULL == pfilename) {
|
|
@@ -45,34 +47,50 @@ unsigned int get_noencrypt_boxs_size(const char* pfilename)
|
|
|
//ftyp box
|
|
|
box_head_t box_head;
|
|
|
fread(&box_head, sizeof(box_head_t), 1, pFile);
|
|
|
- int iboxsize = big_to_small_endian_32bit(box_head.ibox_size);
|
|
|
+ unsigned int uboxsize = big_to_small_endian_32bit(box_head.ibox_size);
|
|
|
if (BOX_FTYP != big_to_small_endian_32bit(box_head.box_type)) {
|
|
|
fclose(pFile);
|
|
|
+ safe_log(pcallback, "get ftyp box failed.");
|
|
|
return 0;
|
|
|
}
|
|
|
- uret += iboxsize;
|
|
|
-
|
|
|
- fseek(pFile, iboxsize - sizeof(box_head_t), SEEK_CUR);
|
|
|
+ safe_log(pcallback, "get ftyp box success, box size is %d.", uboxsize);
|
|
|
+ uret += uboxsize;
|
|
|
+ fseek(pFile, uboxsize - sizeof(box_head_t), SEEK_CUR);
|
|
|
|
|
|
//free box
|
|
|
fread(&box_head, sizeof(box_head_t), 1, pFile);
|
|
|
- iboxsize = big_to_small_endian_32bit(box_head.ibox_size);
|
|
|
- if (TREF_BOX != big_to_small_endian_32bit(box_head.box_type)) {
|
|
|
+ uboxsize = big_to_small_endian_32bit(box_head.ibox_size);
|
|
|
+ if (FREE_BOX != big_to_small_endian_32bit(box_head.box_type)) {
|
|
|
fclose(pFile);
|
|
|
+ safe_log(pcallback, "get free box failed.");
|
|
|
return 0;
|
|
|
}
|
|
|
- uret += iboxsize;
|
|
|
-
|
|
|
- fseek(pFile, iboxsize - sizeof(box_head_t), SEEK_CUR);
|
|
|
+ safe_log(pcallback, "get free box success, box size is %d.", uboxsize);
|
|
|
+ uret += uboxsize;
|
|
|
+ fseek(pFile, uboxsize - sizeof(box_head_t), SEEK_CUR);
|
|
|
|
|
|
//mdat box
|
|
|
fread(&box_head, sizeof(box_head_t), 1, pFile);
|
|
|
- iboxsize = big_to_small_endian_32bit(box_head.ibox_size);
|
|
|
+ uboxsize = big_to_small_endian_32bit(box_head.ibox_size);
|
|
|
if (MDAT_BOX != big_to_small_endian_32bit(box_head.box_type)) {
|
|
|
fclose(pFile);
|
|
|
+ safe_log(pcallback, "get mdat box failed.");
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ safe_log(pcallback, "get mdat box success, box size is %d.", uboxsize);
|
|
|
+ uret += uboxsize;
|
|
|
+ fseek(pFile, uboxsize - sizeof(box_head_t), SEEK_CUR);
|
|
|
+ safe_log(pcallback, "uret is %u.", uret);
|
|
|
+
|
|
|
+ //moov box
|
|
|
+ fread(&box_head, sizeof(box_head_t), 1, pFile);
|
|
|
+ uboxsize = big_to_small_endian_32bit(box_head.ibox_size);
|
|
|
+ if (MOOV_BOX != big_to_small_endian_32bit(box_head.box_type)) {
|
|
|
+ fclose(pFile);
|
|
|
+ safe_log(pcallback, "get moov box failed.");
|
|
|
return 0;
|
|
|
}
|
|
|
- uret += iboxsize;
|
|
|
+ safe_log(pcallback, "get moov box success, box size is %d.", uboxsize);
|
|
|
|
|
|
fclose(pFile);
|
|
|
|