mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
add HLS encryption feature
This commit is contained in:
parent
0d78b908a7
commit
52596a0b04
8 changed files with 378 additions and 11 deletions
|
@ -31,8 +31,11 @@
|
|||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <openssl/aes.h>
|
||||
|
||||
#include <srs_kernel_codec.hpp>
|
||||
#include <srs_kernel_file.hpp>
|
||||
|
||||
|
||||
class SrsBuffer;
|
||||
class SrsTsMessageCache;
|
||||
|
@ -1571,6 +1574,36 @@ public:
|
|||
virtual SrsVideoCodecId video_codec();
|
||||
};
|
||||
|
||||
/*
|
||||
* Used for HLS Encryption
|
||||
*/
|
||||
|
||||
#define HLS_AES_ENCRYPT_BLOCK_LENGTH 188*4
|
||||
|
||||
static char tmpbuf[HLS_AES_ENCRYPT_BLOCK_LENGTH] = {0};
|
||||
static int buflength = 0;
|
||||
|
||||
|
||||
class SrsEncFileWriter: public SrsFileWriter
|
||||
{
|
||||
public:
|
||||
SrsEncFileWriter()
|
||||
{
|
||||
memset(iv,0,16);
|
||||
}
|
||||
virtual ~SrsEncFileWriter(){}
|
||||
|
||||
virtual srs_error_t write(void* buf, size_t count, ssize_t* pnwrite);
|
||||
|
||||
srs_error_t SetEncCfg(unsigned char* key,unsigned char *iv);
|
||||
|
||||
virtual void close();
|
||||
|
||||
private:
|
||||
AES_KEY key;
|
||||
unsigned char iv[16];
|
||||
};
|
||||
|
||||
/**
|
||||
* TS messages cache, to group frames to TS message,
|
||||
* for example, we may write multiple AAC RAW frames to a TS message.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue