2014-04-18 18:49:49 +00:00
|
|
|
// Copyright 2014 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
|
|
|
|
|
|
|
#ifndef MEDIA_FORMATS_MP4_KEY_ROTATION_FRAGMENTER_H_
|
|
|
|
#define MEDIA_FORMATS_MP4_KEY_ROTATION_FRAGMENTER_H_
|
|
|
|
|
2016-04-08 18:41:17 +00:00
|
|
|
#include "packager/media/base/fourccs.h"
|
2014-10-01 22:10:21 +00:00
|
|
|
#include "packager/media/base/key_source.h"
|
2015-08-26 20:25:29 +00:00
|
|
|
#include "packager/media/event/muxer_listener.h"
|
2014-10-01 22:10:21 +00:00
|
|
|
#include "packager/media/formats/mp4/encrypting_fragmenter.h"
|
2014-04-18 18:49:49 +00:00
|
|
|
|
2014-09-19 20:41:13 +00:00
|
|
|
namespace edash_packager {
|
2014-04-18 18:49:49 +00:00
|
|
|
namespace media {
|
|
|
|
namespace mp4 {
|
|
|
|
|
2014-05-08 20:53:08 +00:00
|
|
|
struct MovieFragment;
|
|
|
|
|
|
|
|
/// KeyRotationFragmenter generates MP4 fragments with sample encrypted by
|
|
|
|
/// rotation keys.
|
|
|
|
class KeyRotationFragmenter : public EncryptingFragmenter {
|
2014-04-18 18:49:49 +00:00
|
|
|
public:
|
|
|
|
/// @param moof points to a MovieFragment box.
|
|
|
|
/// @param traf points to a TrackFragment box.
|
|
|
|
/// @param encryption_key_source points to the source which generates
|
|
|
|
/// encryption keys.
|
|
|
|
/// @param track_type indicates whether SD key or HD key should be used to
|
|
|
|
/// encrypt the video content.
|
|
|
|
/// @param crypto_period_duration specifies crypto period duration in units
|
|
|
|
/// of the current track's timescale.
|
|
|
|
/// @param clear_time specifies clear lead duration in units of the current
|
|
|
|
/// track's timescale.
|
2016-04-08 18:41:17 +00:00
|
|
|
/// @param protection_scheme specifies the protection scheme: 'cenc', 'cens',
|
|
|
|
/// 'cbc1', 'cbcs'.
|
2016-04-06 00:28:09 +00:00
|
|
|
/// @param crypt_byte_block indicates number of encrypted blocks (16-byte) in
|
|
|
|
/// pattern based encryption.
|
|
|
|
/// @param skip_byte_block indicates number of unencrypted blocks (16-byte)
|
|
|
|
/// in pattern based encryption.
|
2015-08-26 20:25:29 +00:00
|
|
|
/// @param muxer_listener is a pointer to MuxerListener for notifying
|
|
|
|
/// muxer related events. This may be null.
|
2014-04-18 18:49:49 +00:00
|
|
|
KeyRotationFragmenter(MovieFragment* moof,
|
2016-02-03 22:13:57 +00:00
|
|
|
scoped_refptr<StreamInfo> info,
|
2014-04-18 18:49:49 +00:00
|
|
|
TrackFragment* traf,
|
2014-08-20 23:51:15 +00:00
|
|
|
KeySource* encryption_key_source,
|
|
|
|
KeySource::TrackType track_type,
|
2014-09-30 21:52:21 +00:00
|
|
|
int64_t crypto_period_duration,
|
|
|
|
int64_t clear_time,
|
2016-04-08 18:41:17 +00:00
|
|
|
FourCC protection_scheme,
|
2016-04-06 00:28:09 +00:00
|
|
|
uint8_t crypt_byte_block,
|
|
|
|
uint8_t skip_byte_block,
|
2016-04-08 18:41:17 +00:00
|
|
|
MuxerListener* muxer_listener);
|
2015-07-22 23:40:45 +00:00
|
|
|
~KeyRotationFragmenter() override;
|
2014-04-18 18:49:49 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/// @name Fragmenter implementation overrides.
|
|
|
|
/// @{
|
2015-07-22 23:40:45 +00:00
|
|
|
Status PrepareFragmentForEncryption(bool enable_encryption) override;
|
|
|
|
void FinalizeFragmentForEncryption() override;
|
2014-04-18 18:49:49 +00:00
|
|
|
/// @}
|
|
|
|
|
|
|
|
private:
|
|
|
|
MovieFragment* moof_;
|
|
|
|
|
2014-08-20 23:51:15 +00:00
|
|
|
KeySource* encryption_key_source_;
|
|
|
|
KeySource::TrackType track_type_;
|
2014-09-30 21:52:21 +00:00
|
|
|
const int64_t crypto_period_duration_;
|
2014-04-18 18:49:49 +00:00
|
|
|
size_t prev_crypto_period_index_;
|
|
|
|
|
2015-08-26 20:25:29 +00:00
|
|
|
// For notifying new pssh boxes to the event handler.
|
|
|
|
MuxerListener* const muxer_listener_;
|
|
|
|
|
2014-04-18 18:49:49 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(KeyRotationFragmenter);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mp4
|
|
|
|
} // namespace media
|
2014-09-19 20:41:13 +00:00
|
|
|
} // namespace edash_packager
|
2014-04-18 18:49:49 +00:00
|
|
|
|
|
|
|
#endif // MEDIA_FORMATS_MP4_KEY_ROTATION_FRAGMENTER_H_
|