1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

For #1109, Support without ssl for HLS key.

This commit is contained in:
winlin 2018-08-25 21:15:26 +08:00
parent 522fba99aa
commit ee068cf120
6 changed files with 188 additions and 157 deletions

View file

@ -31,13 +31,10 @@
#include <string>
#include <map>
#include <vector>
#include <openssl/aes.h>
#include <cstring>
#include <srs_kernel_codec.hpp>
#include <srs_kernel_file.hpp>
class SrsBuffer;
class SrsTsMessageCache;
class SrsTsContextWriter;
@ -1575,40 +1572,28 @@ public:
virtual SrsVideoCodecId video_codec();
};
#ifdef SRS_AUTO_SSL
/*
* Used for HLS Encryption
*/
#define HLS_AES_ENCRYPT_BLOCK_LENGTH 188*4
* Used for HLS Encryption
*/
class SrsEncFileWriter: public SrsFileWriter
{
public:
SrsEncFileWriter()
{
memset(iv,0,16);
memset(tmpbuf,0,HLS_AES_ENCRYPT_BLOCK_LENGTH);
buflength = 0;
}
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);
SrsEncFileWriter();
virtual ~SrsEncFileWriter();
public:
virtual srs_error_t write(void* data, size_t count, ssize_t* pnwrite);
virtual void close();
public:
srs_error_t config_cipher(unsigned char* key, unsigned char* iv);
private:
AES_KEY key;
unsigned char* key;
unsigned char iv[16];
private:
char tmpbuf[HLS_AES_ENCRYPT_BLOCK_LENGTH];
int buflength;
char* buf;
int nb_buf;
};
#endif
/**
* TS messages cache, to group frames to TS message,