-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor some Bento4 added methods as subclassed code
- Loading branch information
Showing
5 changed files
with
103 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright (C) 2022 Team Kodi | ||
* This file is part of Kodi - https://kodi.tv | ||
* | ||
* SPDX-License-Identifier: GPL-2.0-or-later | ||
* See LICENSES/README.md for more information. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "../utils/log.h" | ||
|
||
#include <bento4/Ap4.h> | ||
|
||
class Adaptive_CencSampleDecrypter : public AP4_CencSampleDecrypter | ||
{ | ||
public: | ||
Adaptive_CencSampleDecrypter(AP4_CencSingleSampleDecrypter* single_sample_decrypter, | ||
AP4_CencSampleInfoTable* sample_info_table) | ||
: AP4_CencSampleDecrypter(single_sample_decrypter, sample_info_table) | ||
{ | ||
} | ||
|
||
virtual AP4_Result DecryptSampleData(AP4_UI32 poolid, | ||
AP4_DataBuffer& data_in, | ||
AP4_DataBuffer& data_out, | ||
const AP4_UI08* iv) | ||
{ | ||
// increment the sample cursor | ||
unsigned int sample_cursor = m_SampleCursor++; | ||
|
||
// setup the IV | ||
unsigned char iv_block[16]; | ||
if (iv == NULL) | ||
{ | ||
iv = m_SampleInfoTable->GetIv(sample_cursor); | ||
} | ||
if (iv == NULL) | ||
return AP4_ERROR_INVALID_FORMAT; | ||
unsigned int iv_size = m_SampleInfoTable->GetIvSize(); | ||
AP4_CopyMemory(iv_block, iv, iv_size); | ||
if (iv_size != 16) | ||
AP4_SetMemory(&iv_block[iv_size], 0, 16 - iv_size); | ||
|
||
// get the subsample info for this sample if needed | ||
unsigned int subsample_count = 0; | ||
const AP4_UI16* bytes_of_cleartext_data = NULL; | ||
const AP4_UI32* bytes_of_encrypted_data = NULL; | ||
if (m_SampleInfoTable) | ||
{ | ||
AP4_Result result = m_SampleInfoTable->GetSampleInfo( | ||
sample_cursor, subsample_count, bytes_of_cleartext_data, bytes_of_encrypted_data); | ||
if (AP4_FAILED(result)) | ||
return result; | ||
} | ||
|
||
// decrypt the sample | ||
Adaptive_CencSingleSampleDecrypter* decrypter = | ||
dynamic_cast<Adaptive_CencSingleSampleDecrypter*>(m_SingleSampleDecrypter); | ||
if (!decrypter) | ||
{ | ||
LOG::Log(LOGERROR, "Failed to cast AP4 decrypter to Adaptive"); | ||
return AP4_ERROR_INVALID_PARAMETERS; | ||
} | ||
return decrypter->DecryptSampleData(poolid, data_in, data_out, iv_block, subsample_count, | ||
bytes_of_cleartext_data, bytes_of_encrypted_data); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters