diff --git a/bin_lib/windows/ZLMediaKit.dll b/bin_lib/windows/ZLMediaKit.dll new file mode 100755 index 00000000..25fbf3a2 Binary files /dev/null and b/bin_lib/windows/ZLMediaKit.dll differ diff --git a/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/Codec/AACEncoder.h b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/Codec/AACEncoder.h new file mode 100755 index 00000000..d1e9f661 --- /dev/null +++ b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/Codec/AACEncoder.h @@ -0,0 +1,37 @@ +/* + * AACEncoder.h + * + * Created on: 2016年8月11日 + * Author: xzl + */ + +#ifndef CODEC_AACENCODER_H_ +#define CODEC_AACENCODER_H_ + +namespace ZL { +namespace Codec { + +class AACEncoder { +public: + AACEncoder(void); + virtual ~AACEncoder(void); + bool init(int iSampleRate, int iAudioChannel, int iAudioSampleBit); + int inputData(char *pcData, int iLen, unsigned char **ppucOutBuffer); + +private: + unsigned char *m_pucPcmBuf = nullptr; + unsigned int m_uiPcmLen = 0; + + unsigned char *m_pucAacBuf = nullptr; + void *m_hEncoder = nullptr; + + unsigned long m_ulInputSamples = 0; + unsigned long m_ulMaxInputBytes = 0; + unsigned long m_ulMaxOutputBytes = 0; + +}; + +} /* namespace Codec */ +} /* namespace ZL */ + +#endif /* CODEC_AACENCODER_H_ */ diff --git a/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/Codec/H264Encoder.h b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/Codec/H264Encoder.h new file mode 100755 index 00000000..c846c5cb --- /dev/null +++ b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/Codec/H264Encoder.h @@ -0,0 +1,46 @@ +/* + * H264Encoder.h + * + * Created on: 2016年8月11日 + * Author: xzl + */ + +#ifndef CODEC_H264ENCODER_H_ +#define CODEC_H264ENCODER_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus +#include +#ifdef __cplusplus +} +#endif //__cplusplus + +namespace ZL { +namespace Codec { + +class H264Encoder { +public: + typedef struct { + int iType; + int iLength; + uint8_t *pucData; + } H264Frame; + + H264Encoder(void); + virtual ~H264Encoder(void); + bool init(int iWidth, int iHeight, int iFps); + int inputData(char *apcYuv[3], int aiYuvLen[3], int64_t i64Pts, H264Frame **ppFrame); +private: + x264_t* m_pX264Handle = nullptr; + x264_picture_t* m_pPicIn = nullptr; + x264_picture_t* m_pPicOut = nullptr; + H264Frame m_aFrames[10]; +}; + +} /* namespace Codec */ +} /* namespace ZL */ + +#endif /* CODEC_H264ENCODER_H_ */ diff --git a/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/Common/MediaSender.h b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/Common/MediaSender.h new file mode 100755 index 00000000..ea3cacd3 --- /dev/null +++ b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/Common/MediaSender.h @@ -0,0 +1,25 @@ +/* + * MediaSender.h + * + * Created on: 2016年9月1日 + * Author: xzl + */ + +#ifndef SRC_MEDIASENDER_H_ +#define SRC_MEDIASENDER_H_ + +#include "Thread/ThreadPool.h" +using namespace ZL::Thread; + +class MediaSender { +public: + static ThreadPool & sendThread() { + static ThreadPool pool(1); + return pool; + } +private: + MediaSender(); + virtual ~MediaSender(); +}; + +#endif /* SRC_MEDIASENDER_H_ */ diff --git a/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/Common/config.h b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/Common/config.h new file mode 100755 index 00000000..030b6f8b --- /dev/null +++ b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/Common/config.h @@ -0,0 +1,164 @@ +// +// appConfig.h +// ZLMedia +// +// Created by lyl on 16/10/22. +// Copyright © 2016年 jizan. All rights reserved. +// + +#ifndef appConfig_h +#define appConfig_h + +#include "Util/mini.h" +using namespace ZL::Util; + +namespace Config { + +void loaIniConfig(); +////////////TCP最大连接数/////////// +#ifdef __x86_64__ +#define MAX_TCP_SESSION 100000 +#else +#define MAX_TCP_SESSION 128 +#endif + +////////////其他宏定义/////////// +#ifndef MAX +#define MAX(a,b) ((a) > (b) ? (a) : (b) ) +#endif //MAX + +#ifndef MIN +#define MIN(a,b) ((a) < (b) ? (a) : (b) ) +#endif //MIN + +#ifndef CLEAR_ARR +#define CLEAR_ARR(arr) for(auto &item : arr){ item = 0;} +#endif //CLEAR_ARR + + +////////////广播名称/////////// +namespace Broadcast { +extern const char kBroadcastRtspSessionPlay[]; +#define BroadcastRtspSessionPlayArgs const char *app,const char *stream + +extern const char kBroadcastRtspSrcRegisted[]; +#define BroadcastRtspSrcRegistedArgs const char *app,const char *stream + +extern const char kBroadcastRtmpSrcRegisted[]; +#define BroadcastRtmpSrcRegistedArgs const char *app,const char *stream + +extern const char kBroadcastRecordMP4[]; +#define BroadcastRecordMP4Args const Mp4Info &info + +extern const char kBroadcastHttpRequest[]; +#define BroadcastHttpRequestArgs const Parser &parser,HttpSession::HttpResponseInvoker &invoker + +} //namespace Broadcast + +//代理失败最大重试次数 +namespace Proxy { +extern const char kReplayCount[]; +}//namespace Proxy + + +////////////HTTP配置/////////// +namespace Http { +extern const char kPort[]; +extern const char kSSLPort[]; +//http 文件发送缓存大小 +extern const char kSendBufSize[]; +//http 最大请求字节数 +extern const char kMaxReqSize[]; +//http keep-alive秒数 +extern const char kKeepAliveSecond[]; +//http keep-alive最大请求数 +extern const char kMaxReqCount[]; +//http 字符编码 +extern const char kCharSet[]; +//http 服务器名称 +extern const char kServerName[]; +//http 服务器根目录 +extern const char kRootPath[]; +//http 404错误提示内容 +extern const char kNotFound[]; +//HTTP访问url前缀 +extern const char kHttpPrefix[]; +}//namespace Http + +////////////SHELL配置/////////// +namespace Shell { +extern const char kServerName[]; +extern const char kMaxReqSize[]; +extern const char kPort[]; +} //namespace Shell + +////////////RTSP服务器配置/////////// +namespace Rtsp { +#define RTSP_VERSION 1.30 +#define RTSP_BUILDTIME __DATE__" CST" + +extern const char kServerName[]; +extern const char kPort[]; +} //namespace Rtsp + +////////////RTMP服务器配置/////////// +namespace Rtmp { +extern const char kPort[]; +} //namespace RTMP + + +////////////RTP配置/////////// +namespace Rtp { +//RTP打包最大MTU,公网情况下更小 +extern const char kVideoMtuSize[]; +//RTP打包最大MTU,公网情况下更小 +extern const char kAudioMtuSize[]; +//udp方式接受RTP包的最大缓存 +extern const char kUdpBufSize[]; +//RTP排序缓存最大个数 +extern const char kMaxRtpCount[]; +//如果RTP序列正确次数累计达到该数字就启动清空排序缓存 +extern const char kClearCount[]; +//最大RTP时间为13个小时,每13小时回环一次 +extern const char kCycleMS[]; +} //namespace Rtsp + +////////////组播配置/////////// +namespace MultiCast { +//组播分配起始地址 +extern const char kAddrMin[]; +//组播分配截止地址 +extern const char kAddrMax[]; +//组播TTL +extern const char kUdpTTL[]; +} //namespace MultiCast + +////////////录像配置/////////// +namespace Record { +//查看录像的应用名称 +extern const char kAppName[]; +//每次流化MP4文件的时长,单位毫秒 +extern const char kSampleMS[]; +//MP4文件录制大小,不能太大,否则MP4Close函数执行事件太长 +extern const char kFileSecond[]; +//Rtsp访问url前缀 +extern const char kRtspPrefix[]; +//录制文件路径 +extern const char kFilePath[]; +} //namespace Record + +////////////HLS相关配置/////////// +namespace Hls { +//HLS切片时长,单位秒 +extern const char kSegmentDuration[]; +//HLS切片个数 +extern const char kSegmentNum[]; +//HLS文件写缓存大小 +extern const char kFileBufSize[]; +//录制文件路径 +extern const char kFilePath[]; +} //namespace Hls + +} // namespace Config + +#endif /* appConfig_h */ diff --git a/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/Device/Device.h b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/Device/Device.h new file mode 100755 index 00000000..3c4582d2 --- /dev/null +++ b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/Device/Device.h @@ -0,0 +1,107 @@ +/* + * Device.h + * + * Created on: 2016年8月10日 + * Author: xzl + */ + +#ifndef DEVICE_DEVICE_H_ +#define DEVICE_DEVICE_H_ + +#include +#include +#include +#include "Util/util.h" +#include "RTP/RtpMakerAAC.h" +#include "RTP/RtpMakerH264.h" +#include "Rtsp/RtspToRtmpMediaSource.h" + +using namespace std; +using namespace ZL::Rtsp; +using namespace ZL::Util; + +#ifdef ENABLE_FAAC +#include "Codec/AACEncoder.h" +using namespace ZL::Codec; +#endif //ENABLE_FAAC + +#ifdef ENABLE_X264 +#include "Codec/H264Encoder.h" +using namespace ZL::Codec; +#endif //ENABLE_X264 + +namespace ZL { +namespace DEV { + +class VideoInfo { +public: + int iWidth; + int iHeight; + float iFrameRate; +}; +class AudioInfo { +public: + int iChannel; + int iSampleBit; + int iSampleRate; +}; + +class DevChannel { +public: + typedef std::shared_ptr Ptr; + DevChannel(const char *strApp, const char *strId,float fDuration = 0,bool bLiveStream = true); + virtual ~DevChannel(); + + void initVideo(const VideoInfo &info); + void initAudio(const AudioInfo &info); + + void inputYUV(char *apcYuv[3], int aiYuvLen[3], uint32_t uiStamp); + void inputPCM(char *pcData, int iDataLen, uint32_t uiStamp); + + void inputH264(char *pcData, int iDataLen, uint32_t uiStamp); + void inputAAC(char *pcData, int iDataLen, uint32_t uiStamp); +#ifdef ENABLE_RTSP2RTMP + int readerCount() { + return m_mediaSrc ? m_mediaSrc->readerCount() : 0; + } + void updateTimeStamp(uint32_t uiStamp){ + m_mediaSrc->updateTimeStamp(uiStamp); + } +#endif //ENABLE_RTSP2RTMP + void setOnSeek(const function &onSeek){ + m_mediaSrc->setOnSeek(onSeek); + } + void setOnStamp(const function &cb) { + m_mediaSrc->setOnStamp(cb); + } +private: + inline void makeSDP_264(unsigned char *pucData, int iDataLen); + inline void makeSDP_AAC(unsigned char *pucData, int iDataLen); + inline void makeSDP(const string& strSdp); +#ifdef ENABLE_X264 + std::shared_ptr m_pH264Enc; +#endif //ENABLE_X264 + +#ifdef ENABLE_FAAC + std::shared_ptr m_pAacEnc; +#endif //ENABLE_FAAC + RtpMaker_AAC::Ptr m_pRtpMaker_aac; + RtpMaker_H264::Ptr m_pRtpMaker_h264; + RtspToRtmpMediaSource::Ptr m_mediaSrc; + string m_strSDP; + bool m_bSdp_gotH264 = false; + bool m_bSdp_gotAAC = false; + + unsigned char m_aucSPS[256]; + unsigned int m_uiSPSLen = 0; + unsigned char m_aucPPS[256]; + unsigned int m_uiPPSLen = 0; + std::shared_ptr m_video; + std::shared_ptr m_audio; +}; + + +} /* namespace DEV */ +} /* namespace ZL */ + +#endif /* DEVICE_DEVICE_H_ */ diff --git a/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/Device/PlayerProxy.h b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/Device/PlayerProxy.h new file mode 100755 index 00000000..a05b3faa --- /dev/null +++ b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/Device/PlayerProxy.h @@ -0,0 +1,51 @@ +/* + * PlyerProxy.h + * + * Created on: 2016年12月6日 + * Author: xzl + */ + +#ifndef SRC_DEVICE_PLAYERPROXY_H_ +#define SRC_DEVICE_PLAYERPROXY_H_ + +#include +#include "Device.h" +#include "Player/MediaPlayer.h" +#include "Util/TimeTicker.h" + +using namespace std; +using namespace ZL::Player; + +namespace ZL { +namespace DEV { + +class PlayerProxy :public MediaPlayer, public std::enable_shared_from_this{ +public: + typedef std::shared_ptr Ptr; + //设置代理时间,0为永久,其他为代理秒数 + //设置方法:proxy[PlayerProxy::kAliveSecond] = 100; + static const char kAliveSecond[]; + + PlayerProxy(const char *strApp, const char *strSrc); + virtual ~PlayerProxy(); + void play(const char* strUrl) override; + void setOnExpired(const function &cb){ + onExpired = cb; + } +private : + DevChannel::Ptr m_pChn; + Ticker m_aliveTicker; + uint32_t m_aliveSecond = 0; + function onExpired; + string m_strApp; + string m_strSrc; + void initMedia(); + void rePlay(const string &strUrl,uint64_t iFailedCnt); + void checkExpired(); + void expired(); +}; + +} /* namespace Player */ +} /* namespace ZL */ + +#endif /* SRC_DEVICE_PLAYERPROXY_H_ */ diff --git a/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/Device/base64.h b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/Device/base64.h new file mode 100755 index 00000000..6da4f28f --- /dev/null +++ b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/Device/base64.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2006 Ryan Martell. (rdm4@martellventures.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) +#ifndef AVUTIL_BASE64_H +#define AVUTIL_BASE64_H + +#include + +/** + * Decode a base64-encoded string. + * + * @param out buffer for decoded data + * @param in null-terminated input string + * @param out_size size in bytes of the out buffer, must be at + * least 3/4 of the length of in + * @return number of bytes written, or a negative value in case of + * invalid input + */ +int av_base64_decode(uint8_t *out, const char *in, int out_size); + +/** + * Encode data to base64 and null-terminate. + * + * @param out buffer for encoded data + * @param out_size size in bytes of the output buffer, must be at + * least AV_BASE64_SIZE(in_size) + * @param in_size size in bytes of the 'in' buffer + * @return 'out' or NULL in case of error + */ +char *av_base64_encode(char *out, int out_size, const uint8_t *in, int in_size); + +/** + * Calculate the output size needed to base64-encode x bytes. + */ +#define AV_BASE64_SIZE(x) (((x)+2) / 3 * 4 + 1) + +#endif /* AVUTIL_BASE64_H */ diff --git a/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/H264/H264Parser.h b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/H264/H264Parser.h new file mode 100755 index 00000000..849ecf3a --- /dev/null +++ b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/H264/H264Parser.h @@ -0,0 +1,58 @@ +// +// H264Parser.h +// MediaPlayer +// +// Created by xzl on 2017/1/16. +// Copyright © 2017年 jizan. All rights reserved. +// + +#ifndef H264Parser_h +#define H264Parser_h + +#include +#include +#include "h264_poc.h" +#include "h264_parser.h" +using namespace std; + +#ifndef INT32_MAX +#define INT32_MAX 0x7FFFFFFF +#endif//INT32_MAX + +class H264Parser{ +public: + H264Parser(); + virtual ~H264Parser(); + void inputH264(const string &h264,uint32_t dts); + + int32_t getPOC() const{ + return m_iNowPOC; + } + int getSliceType() const{ + return m_shdr.slice_type; + } + int getNaluType() const{ + return m_nalu.nal_unit_type; + } + uint32_t getPts() const{ + return m_iNowPTS; + } +private: + media::H264Parser m_parser; + media::H264POC m_poc; + media::H264NALU m_nalu; + media::H264SliceHeader m_shdr; + + int32_t m_iNowPOC = INT32_MAX; + int32_t m_iLastPOC = INT32_MAX; + + uint32_t m_iNowPTS = INT32_MAX; + uint32_t m_iLastPTS = INT32_MAX; + int32_t m_iMsPerPOC = 30; + + void computePts(uint32_t dts); + + +}; + +#endif /* H264Parser_hpp */ diff --git a/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/H264/SPSParser.h b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/H264/SPSParser.h new file mode 100755 index 00000000..29972f2b --- /dev/null +++ b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/H264/SPSParser.h @@ -0,0 +1,192 @@ +/*************************************************************************************** + ***************************************************************************************/ +#ifndef _JZAN_SPS_PPS_H_ +#define _JZAN_SPS_PPS_H_ + +#if defined (__cplusplus) + extern "C" { +#endif + +#define QP_MAX_NUM (51 + 6*6) // The maximum supported qp + +/** + * Chromaticity coordinates of the source primaries. + */ +enum T_AVColorPrimaries { + AVCOL_PRI_RESERVED0 = 0, + AVCOL_PRI_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B + AVCOL_PRI_UNSPECIFIED = 2, + AVCOL_PRI_RESERVED = 3, + AVCOL_PRI_BT470M = 4, ///< also FCC Title 47 Code of Federal Regulations 73.682 (a)(20) + + AVCOL_PRI_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM + AVCOL_PRI_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC + AVCOL_PRI_SMPTE240M = 7, ///< functionally identical to above + AVCOL_PRI_FILM = 8, ///< colour filters using Illuminant C + AVCOL_PRI_BT2020 = 9, ///< ITU-R BT2020 + AVCOL_PRI_NB, ///< Not part of ABI +}; + +/** + * Color Transfer Characteristic. + */ +enum T_AVColorTransferCharacteristic { + AVCOL_TRC_RESERVED0 = 0, + AVCOL_TRC_BT709 = 1, ///< also ITU-R BT1361 + AVCOL_TRC_UNSPECIFIED = 2, + AVCOL_TRC_RESERVED = 3, + AVCOL_TRC_GAMMA22 = 4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM + AVCOL_TRC_GAMMA28 = 5, ///< also ITU-R BT470BG + AVCOL_TRC_SMPTE170M = 6, ///< also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC + AVCOL_TRC_SMPTE240M = 7, + AVCOL_TRC_LINEAR = 8, ///< "Linear transfer characteristics" + AVCOL_TRC_LOG = 9, ///< "Logarithmic transfer characteristic (100:1 range)" + AVCOL_TRC_LOG_SQRT = 10, ///< "Logarithmic transfer characteristic (100 * Sqrt(10) : 1 range)" + AVCOL_TRC_IEC61966_2_4 = 11, ///< IEC 61966-2-4 + AVCOL_TRC_BT1361_ECG = 12, ///< ITU-R BT1361 Extended Colour Gamut + AVCOL_TRC_IEC61966_2_1 = 13, ///< IEC 61966-2-1 (sRGB or sYCC) + AVCOL_TRC_BT2020_10 = 14, ///< ITU-R BT2020 for 10 bit system + AVCOL_TRC_BT2020_12 = 15, ///< ITU-R BT2020 for 12 bit system + AVCOL_TRC_NB, ///< Not part of ABI +}; + +/** + * YUV tColorspace type. + */ +enum T_AVColorSpace { + AVCOL_SPC_RGB = 0, ///< order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB) + AVCOL_SPC_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B + AVCOL_SPC_UNSPECIFIED = 2, + AVCOL_SPC_RESERVED = 3, + AVCOL_SPC_FCC = 4, ///< FCC Title 47 Code of Federal Regulations 73.682 (a)(20) + AVCOL_SPC_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 + AVCOL_SPC_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above + AVCOL_SPC_SMPTE240M = 7, + AVCOL_SPC_YCOCG = 8, ///< Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16 + AVCOL_SPC_BT2020_NCL = 9, ///< ITU-R BT2020 non-constant luminance system + AVCOL_SPC_BT2020_CL = 10, ///< ITU-R BT2020 constant luminance system + AVCOL_SPC_NB, ///< Not part of ABI +}; + + +/** + * rational number numerator/denominator + */ +typedef struct T_AVRational{ + int num; ///< numerator + int den; ///< denominator +} T_AVRational; + + +/*** + * Sequence parameter set + * ¿É²Î¿¼H264±ê×¼µÚ7½ÚºÍ¸½Â¼D E + */ +#define Extended_SAR 255 + +/** + * Sequence parameter set + */ +typedef struct T_SPS { + unsigned int uiSpsId; + int iProfileIdc; + int iLevelIdc; + int iChromaFormatIdc; + int iTransformBypass; ///< qpprime_y_zero_transform_bypass_flag + int iLog2MaxFrameNum; ///< log2_max_frame_num_minus4 + 4 + int iPocType; ///< pic_order_cnt_type + int iLog2MaxPocLsb; ///< log2_max_pic_order_cnt_lsb_minus4 + int iDeltaPicOrderAlwaysZeroFlag; + int iOffsetForNonRefPic; + int iOffsetForTopToBottomField; + int iPocCycleLength; ///< num_ref_frames_in_pic_order_cnt_cycle + int iRefFrameCount; ///< num_ref_frames + int iGapsInFrameNumAllowedFlag; + int iMbWidth; ///< pic_width_in_mbs_minus1 + 1 + int iMbHeight; ///< pic_height_in_map_units_minus1 + 1 + int iFrameMbsOnlyFlag; + int iMbAff; ///< mb_adaptive_frame_field_flag + int iDirect8x8InferenceFlag; + int iCrop; ///< frame_cropping_flag + + /* those 4 are already in luma samples */ + unsigned int uiCropLeft; ///< frame_cropping_rect_left_offset + unsigned int uiCropRight; ///< frame_cropping_rect_right_offset + unsigned int uiCropTop; ///< frame_cropping_rect_top_offset + unsigned int uiCropBottom; ///< frame_cropping_rect_bottom_offset + int iVuiParametersPresentFlag; + T_AVRational tSar; + int iVideoSignalTypePresentFlag; + int iFullRange; + int iColourDescriptionPresentFlag; + enum T_AVColorPrimaries tColorPrimaries; + enum T_AVColorTransferCharacteristic tColorTrc; + enum T_AVColorSpace tColorspace; + int iTimingInfoPresentFlag; + uint32_t u32NumUnitsInTick; + uint32_t u32TimeScale; + int iFixedFrameRateFlag; + short asOffsetForRefFrame[256]; // FIXME dyn aloc? + int iBitstreamRestrictionFlag; + int iNumReorderFrames; + int iScalingMatrixPresent; + uint8_t aau8ScalingMatrix4[6][16]; + uint8_t aau8ScalingMatrix8[6][64]; + int iNalHrdParametersPresentFlag; + int iVclHrdParametersPresentFlag; + int iPicStructPresentFlag; + int iTimeOffsetLength; + int iCpbCnt; ///< See H.264 E.1.2 + int iInitialCpbRemovalDelayLength; ///< initial_cpb_removal_delay_length_minus1 + 1 + int iCpbRemovalDelayLength; ///< cpb_removal_delay_length_minus1 + 1 + int iDpbOutputDelayLength; ///< dpb_output_delay_length_minus1 + 1 + int iBitDepthLuma; ///< bit_depth_luma_minus8 + 8 + int iBitDepthChroma; ///< bit_depth_chroma_minus8 + 8 + int iResidualColorTransformFlag; ///< residual_colour_transform_flag + int iConstraintSetFlags; ///< constraint_set[0-3]_flag + int iNew; ///< flag to keep track if the decoder context needs re-init due to changed SPS +} T_SPS; + +/** + * Picture parameter set + */ +typedef struct T_PPS { + unsigned int uiSpsId; + int iCabac; ///< entropy_coding_mode_flag + int iPicOrderPresent; ///< pic_order_present_flag + int iSliceGroupCount; ///< num_slice_groups_minus1 + 1 + int iMbSliceGroupMapType; + unsigned int auiRefCount[2]; ///< num_ref_idx_l0/1_active_minus1 + 1 + int iWeightedPred; ///< weighted_pred_flag + int iWeightedBipredIdc; + int iInitQp; ///< pic_init_qp_minus26 + 26 + int iInitQs; ///< pic_init_qs_minus26 + 26 + int aiChromaQpIndexOffset[2]; + int iDeblockingFilterParametersPresent; ///< deblocking_filter_parameters_present_flag + int iConstrainedIntraPred; ///< constrained_intra_pred_flag + int iRedundantPicCntPresent; ///< redundant_pic_cnt_present_flag + int iTransform8x8Mode; ///< transform_8x8_mode_flag + uint8_t aau8ScalingMatrix4[6][16]; + uint8_t aau8ScalingMatrix8[6][64]; + uint8_t u8ChromaQpTable[2][QP_MAX_NUM+1]; ///< pre-scaled (with aiChromaQpIndexOffset) version of qp_table + int iChromaQpDiff; +} T_PPS; + +typedef struct T_GetBitContext{ + uint8_t *pu8Buf; /*Ö¸ÏòSPS start*/ + int iBufSize; /*SPS ³¤¶È*/ + int iBitPos; /*bitÒѶÁȡλÖÃ*/ + int iTotalBit; /*bit×ܳ¤¶È*/ + int iCurBitPos; /*µ±Ç°¶ÁȡλÖÃ*/ +}T_GetBitContext; + + +int h264DecSeqParameterSet(void *pvBuf, T_SPS *ptSps); +void h264GetWidthHeight(T_SPS *ptSps, int *piWidth, int *piHeight); +void h264GeFramerate(T_SPS *ptSps, float *pfFramerate); + +#if defined (__cplusplus) +} +#endif + +#endif diff --git a/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/H264/h264_bit_reader.h b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/H264/h264_bit_reader.h new file mode 100755 index 00000000..75569e48 --- /dev/null +++ b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/H264/h264_bit_reader.h @@ -0,0 +1,81 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// This file contains an implementation of an H264 Annex-B video stream parser. + +#ifndef MEDIA_FILTERS_H264_BIT_READER_H_ +#define MEDIA_FILTERS_H264_BIT_READER_H_ + +#include +#include +#include +#include "macros.h" + +using namespace std; + +namespace media { + + // A class to provide bit-granularity reading of H.264 streams. + // This is not a generic bit reader class, as it takes into account + // H.264 stream-specific constraints, such as skipping emulation-prevention + // bytes and stop bits. See spec for more details. + class MEDIA_EXPORT H264BitReader { + public: + H264BitReader(); + ~H264BitReader(); + + // Initialize the reader to start reading at |data|, |size| being size + // of |data| in bytes. + // Return false on insufficient size of stream.. + // TODO(posciak,fischman): consider replacing Initialize() with + // heap-allocating and creating bit readers on demand instead. + bool Initialize(const uint8_t* data, off_t size); + + // Read |num_bits| next bits from stream and return in |*out|, first bit + // from the stream starting at |num_bits| position in |*out|. + // |num_bits| may be 1-32, inclusive. + // Return false if the given number of bits cannot be read (not enough + // bits in the stream), true otherwise. + bool ReadBits(int num_bits, int* out); + + // Return the number of bits left in the stream. + off_t NumBitsLeft(); + + // See the definition of more_rbsp_data() in spec. + bool HasMoreRBSPData(); + + // Return the number of emulation prevention bytes already read. + size_t NumEmulationPreventionBytesRead(); + + private: + // Advance to the next byte, loading it into curr_byte_. + // Return false on end of stream. + bool UpdateCurrByte(); + + // Pointer to the next unread (not in curr_byte_) byte in the stream. + const uint8_t* data_; + + // Bytes left in the stream (without the curr_byte_). + off_t bytes_left_; + + // Contents of the current byte; first unread bit starting at position + // 8 - num_remaining_bits_in_curr_byte_ from MSB. + int curr_byte_; + + // Number of bits remaining in curr_byte_ + int num_remaining_bits_in_curr_byte_; + + // Used in emulation prevention three byte detection (see spec). + // Initially set to 0xffff to accept all initial two-byte sequences. + int prev_two_bytes_; + + // Number of emulation preventation bytes (0x000003) we met. + size_t emulation_prevention_bytes_; + + DISALLOW_COPY_AND_ASSIGN(H264BitReader); + }; + +} // namespace media + +#endif // MEDIA_FILTERS_H264_BIT_READER_H_ diff --git a/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/H264/h264_parser.h b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/H264/h264_parser.h new file mode 100755 index 00000000..b2298257 --- /dev/null +++ b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/H264/h264_parser.h @@ -0,0 +1,491 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// This file contains an implementation of an H264 Annex-B video stream parser. + +#ifndef MEDIA_FILTERS_H264_PARSER_H_ +#define MEDIA_FILTERS_H264_PARSER_H_ + +#include +#include +#include + +#include +#include + +#include "macros.h" +#include "h264_bit_reader.h" +#include "ranges.h" + +using namespace std; + +namespace media { + + struct SubsampleEntry { + uint32_t clear_bytes; + uint32_t cypher_bytes; + }; + + // For explanations of each struct and its members, see H.264 specification + // at http://www.itu.int/rec/T-REC-H.264. + struct MEDIA_EXPORT H264NALU { + H264NALU(); + + enum Type { + kUnspecified = 0, + kNonIDRSlice = 1, + kSliceDataA = 2, + kSliceDataB = 3, + kSliceDataC = 4, + kIDRSlice = 5, + kSEIMessage = 6, + kSPS = 7, + kPPS = 8, + kAUD = 9, + kEOSeq = 10, + kEOStream = 11, + kFiller = 12, + kSPSExt = 13, + kReserved14 = 14, + kReserved15 = 15, + kReserved16 = 16, + kReserved17 = 17, + kReserved18 = 18, + kCodedSliceAux = 19, + kCodedSliceExtension = 20, + }; + + // After (without) start code; we don't own the underlying memory + // and a shallow copy should be made when copying this struct. + const uint8_t* data; + off_t size; // From after start code to start code of next NALU (or EOS). + + int nal_ref_idc; + int nal_unit_type; + }; + + enum { + kH264ScalingList4x4Length = 16, + kH264ScalingList8x8Length = 64, + }; + + struct MEDIA_EXPORT H264SPS { + H264SPS(); + + enum H264ProfileIDC { + kProfileIDCBaseline = 66, + kProfileIDCConstrainedBaseline = kProfileIDCBaseline, + kProfileIDCMain = 77, + kProfileIDScalableBaseline = 83, + kProfileIDScalableHigh = 86, + kProfileIDCHigh = 100, + kProfileIDHigh10 = 110, + kProfileIDSMultiviewHigh = 118, + kProfileIDHigh422 = 122, + kProfileIDStereoHigh = 128, + kProfileIDHigh444Predictive = 244, + }; + + enum AspectRatioIdc { + kExtendedSar = 255, + }; + + enum { + // Constants for HRD parameters (spec ch. E.2.2). + kBitRateScaleConstantTerm = 6, // Equation E-37. + kCPBSizeScaleConstantTerm = 4, // Equation E-38. + kDefaultInitialCPBRemovalDelayLength = 24, + kDefaultDPBOutputDelayLength = 24, + kDefaultTimeOffsetLength = 24, + }; + + int profile_idc; + bool constraint_set0_flag; + bool constraint_set1_flag; + bool constraint_set2_flag; + bool constraint_set3_flag; + bool constraint_set4_flag; + bool constraint_set5_flag; + int level_idc; + int seq_parameter_set_id; + + int chroma_format_idc; + bool separate_colour_plane_flag; + int bit_depth_luma_minus8; + int bit_depth_chroma_minus8; + bool qpprime_y_zero_transform_bypass_flag; + + bool seq_scaling_matrix_present_flag; + int scaling_list4x4[6][kH264ScalingList4x4Length]; + int scaling_list8x8[6][kH264ScalingList8x8Length]; + + int log2_max_frame_num_minus4; + int pic_order_cnt_type; + int log2_max_pic_order_cnt_lsb_minus4; + bool delta_pic_order_always_zero_flag; + int offset_for_non_ref_pic; + int offset_for_top_to_bottom_field; + int num_ref_frames_in_pic_order_cnt_cycle; + int expected_delta_per_pic_order_cnt_cycle; // calculated + int offset_for_ref_frame[255]; + int max_num_ref_frames; + bool gaps_in_frame_num_value_allowed_flag; + int pic_width_in_mbs_minus1; + int pic_height_in_map_units_minus1; + bool frame_mbs_only_flag; + bool mb_adaptive_frame_field_flag; + bool direct_8x8_inference_flag; + bool frame_cropping_flag; + int frame_crop_left_offset; + int frame_crop_right_offset; + int frame_crop_top_offset; + int frame_crop_bottom_offset; + + bool vui_parameters_present_flag; + int sar_width; // Set to 0 when not specified. + int sar_height; // Set to 0 when not specified. + bool bitstream_restriction_flag; + int max_num_reorder_frames; + int max_dec_frame_buffering; + bool timing_info_present_flag; + int num_units_in_tick; + int time_scale; + bool fixed_frame_rate_flag; + + // TODO(posciak): actually parse these instead of ParseAndIgnoreHRDParameters. + bool nal_hrd_parameters_present_flag; + int cpb_cnt_minus1; + int bit_rate_scale; + int cpb_size_scale; + int bit_rate_value_minus1[32]; + int cpb_size_value_minus1[32]; + bool cbr_flag[32]; + int initial_cpb_removal_delay_length_minus_1; + int cpb_removal_delay_length_minus1; + int dpb_output_delay_length_minus1; + int time_offset_length; + + bool low_delay_hrd_flag; + + int chroma_array_type; + }; + + struct MEDIA_EXPORT H264PPS { + H264PPS(); + + int pic_parameter_set_id; + int seq_parameter_set_id; + bool entropy_coding_mode_flag; + bool bottom_field_pic_order_in_frame_present_flag; + int num_slice_groups_minus1; + // TODO(posciak): Slice groups not implemented, could be added at some point. + int num_ref_idx_l0_default_active_minus1; + int num_ref_idx_l1_default_active_minus1; + bool weighted_pred_flag; + int weighted_bipred_idc; + int pic_init_qp_minus26; + int pic_init_qs_minus26; + int chroma_qp_index_offset; + bool deblocking_filter_control_present_flag; + bool constrained_intra_pred_flag; + bool redundant_pic_cnt_present_flag; + bool transform_8x8_mode_flag; + + bool pic_scaling_matrix_present_flag; + int scaling_list4x4[6][kH264ScalingList4x4Length]; + int scaling_list8x8[6][kH264ScalingList8x8Length]; + + int second_chroma_qp_index_offset; + }; + + struct MEDIA_EXPORT H264ModificationOfPicNum { + int modification_of_pic_nums_idc; + union { + int abs_diff_pic_num_minus1; + int long_term_pic_num; + }; + }; + + struct MEDIA_EXPORT H264WeightingFactors { + bool luma_weight_flag; + bool chroma_weight_flag; + int luma_weight[32]; + int luma_offset[32]; + int chroma_weight[32][2]; + int chroma_offset[32][2]; + }; + + struct MEDIA_EXPORT H264DecRefPicMarking { + int memory_mgmnt_control_operation; + int difference_of_pic_nums_minus1; + int long_term_pic_num; + int long_term_frame_idx; + int max_long_term_frame_idx_plus1; + }; + + struct MEDIA_EXPORT H264SliceHeader { + H264SliceHeader(); + + enum { + kRefListSize = 32, + kRefListModSize = kRefListSize + }; + + enum Type { + kPSlice = 0, + kBSlice = 1, + kISlice = 2, + kSPSlice = 3, + kSISlice = 4, + }; + + bool IsPSlice() const; + bool IsBSlice() const; + bool IsISlice() const; + bool IsSPSlice() const; + bool IsSISlice() const; + + bool idr_pic_flag; // from NAL header + int nal_ref_idc; // from NAL header + const uint8_t* nalu_data; // from NAL header + off_t nalu_size; // from NAL header + off_t header_bit_size; // calculated + + int first_mb_in_slice; + int slice_type; + int pic_parameter_set_id; + int colour_plane_id; // TODO(posciak): use this! http://crbug.com/139878 + int frame_num; + bool field_pic_flag; + bool bottom_field_flag; + int idr_pic_id; + int pic_order_cnt_lsb; + int delta_pic_order_cnt_bottom; + int delta_pic_order_cnt0; + int delta_pic_order_cnt1; + int redundant_pic_cnt; + bool direct_spatial_mv_pred_flag; + + bool num_ref_idx_active_override_flag; + int num_ref_idx_l0_active_minus1; + int num_ref_idx_l1_active_minus1; + bool ref_pic_list_modification_flag_l0; + bool ref_pic_list_modification_flag_l1; + H264ModificationOfPicNum ref_list_l0_modifications[kRefListModSize]; + H264ModificationOfPicNum ref_list_l1_modifications[kRefListModSize]; + + int luma_log2_weight_denom; + int chroma_log2_weight_denom; + + bool luma_weight_l0_flag; + bool chroma_weight_l0_flag; + H264WeightingFactors pred_weight_table_l0; + + bool luma_weight_l1_flag; + bool chroma_weight_l1_flag; + H264WeightingFactors pred_weight_table_l1; + + bool no_output_of_prior_pics_flag; + bool long_term_reference_flag; + + bool adaptive_ref_pic_marking_mode_flag; + H264DecRefPicMarking ref_pic_marking[kRefListSize]; + + int cabac_init_idc; + int slice_qp_delta; + bool sp_for_switch_flag; + int slice_qs_delta; + int disable_deblocking_filter_idc; + int slice_alpha_c0_offset_div2; + int slice_beta_offset_div2; + + // Calculated. + // Size in bits of dec_ref_pic_marking() syntax element. + size_t dec_ref_pic_marking_bit_size; + size_t pic_order_cnt_bit_size; + }; + + struct H264SEIRecoveryPoint { + int recovery_frame_cnt; + bool exact_match_flag; + bool broken_link_flag; + int changing_slice_group_idc; + }; + + struct MEDIA_EXPORT H264SEIMessage { + H264SEIMessage(); + + enum Type { + kSEIRecoveryPoint = 6, + }; + + int type; + int payload_size; + union { + // Placeholder; in future more supported types will contribute to more + // union members here. + H264SEIRecoveryPoint recovery_point; + }; + }; + + // Class to parse an Annex-B H.264 stream, + // as specified in chapters 7 and Annex B of the H.264 spec. + class MEDIA_EXPORT H264Parser { + public: + enum Result { + kOk, + kInvalidStream, // error in stream + kUnsupportedStream, // stream not supported by the parser + kEOStream, // end of stream + }; + + // Find offset from start of data to next NALU start code + // and size of found start code (3 or 4 bytes). + // If no start code is found, offset is pointing to the first unprocessed byte + // (i.e. the first byte that was not considered as a possible start of a start + // code) and |*start_code_size| is set to 0. + // Preconditions: + // - |data_size| >= 0 + // Postconditions: + // - |*offset| is between 0 and |data_size| included. + // It is strictly less than |data_size| if |data_size| > 0. + // - |*start_code_size| is either 0, 3 or 4. + static bool FindStartCode(const uint8_t* data, + off_t data_size, + off_t* offset, + off_t* start_code_size); + + // Wrapper for FindStartCode() that skips over start codes that + // may appear inside of |encrypted_ranges_|. + // Returns true if a start code was found. Otherwise returns false. + static bool FindStartCodeInClearRanges(const uint8_t* data, + off_t data_size, + const Ranges& ranges, + off_t* offset, + off_t* start_code_size); + H264Parser(); + ~H264Parser(); + + void Reset(); + // Set current stream pointer to |stream| of |stream_size| in bytes, + // |stream| owned by caller. + // |subsamples| contains information about what parts of |stream| are + // encrypted. + void SetStream(const uint8_t* stream, off_t stream_size); + void SetEncryptedStream(const uint8_t* stream, + off_t stream_size, + const std::vector& subsamples); + + // Read the stream to find the next NALU, identify it and return + // that information in |*nalu|. This advances the stream to the beginning + // of this NALU, but not past it, so subsequent calls to NALU-specific + // parsing functions (ParseSPS, etc.) will parse this NALU. + // If the caller wishes to skip the current NALU, it can call this function + // again, instead of any NALU-type specific parse functions below. + Result AdvanceToNextNALU(H264NALU* nalu); + + // NALU-specific parsing functions. + // These should be called after AdvanceToNextNALU(). + + // SPSes and PPSes are owned by the parser class and the memory for their + // structures is managed here, not by the caller, as they are reused + // across NALUs. + // + // Parse an SPS/PPS NALU and save their data in the parser, returning id + // of the parsed structure in |*pps_id|/|*sps_id|. + // To get a pointer to a given SPS/PPS structure, use GetSPS()/GetPPS(), + // passing the returned |*sps_id|/|*pps_id| as parameter. + // TODO(posciak,fischman): consider replacing returning Result from Parse*() + // methods with a scoped_ptr and adding an AtEOS() function to check for EOS + // if Parse*() return NULL. + Result ParseSPS(int* sps_id); + Result ParsePPS(int* pps_id); + + // Return a pointer to SPS/PPS with given |sps_id|/|pps_id| or NULL if not + // present. + const H264SPS* GetSPS(int sps_id) const; + const H264PPS* GetPPS(int pps_id) const; + + // Slice headers and SEI messages are not used across NALUs by the parser + // and can be discarded after current NALU, so the parser does not store + // them, nor does it manage their memory. + // The caller has to provide and manage it instead. + + // Parse a slice header, returning it in |*shdr|. |*nalu| must be set to + // the NALU returned from AdvanceToNextNALU() and corresponding to |*shdr|. + Result ParseSliceHeader(const H264NALU& nalu, H264SliceHeader* shdr); + + // Parse a SEI message, returning it in |*sei_msg|, provided and managed + // by the caller. + Result ParseSEI(H264SEIMessage* sei_msg); + + private: + // Move the stream pointer to the beginning of the next NALU, + // i.e. pointing at the next start code. + // Return true if a NALU has been found. + // If a NALU is found: + // - its size in bytes is returned in |*nalu_size| and includes + // the start code as well as the trailing zero bits. + // - the size in bytes of the start code is returned in |*start_code_size|. + bool LocateNALU(off_t* nalu_size, off_t* start_code_size); + + // Exp-Golomb code parsing as specified in chapter 9.1 of the spec. + // Read one unsigned exp-Golomb code from the stream and return in |*val|. + Result ReadUE(int* val); + + // Read one signed exp-Golomb code from the stream and return in |*val|. + Result ReadSE(int* val); + + // Parse scaling lists (see spec). + Result ParseScalingList(int size, int* scaling_list, bool* use_default); + Result ParseSPSScalingLists(H264SPS* sps); + Result ParsePPSScalingLists(const H264SPS& sps, H264PPS* pps); + + // Parse optional VUI parameters in SPS (see spec). + Result ParseVUIParameters(H264SPS* sps); + // Set |hrd_parameters_present| to true only if they are present. + Result ParseAndIgnoreHRDParameters(bool* hrd_parameters_present); + + // Parse reference picture lists' modifications (see spec). + Result ParseRefPicListModifications(H264SliceHeader* shdr); + Result ParseRefPicListModification(int num_ref_idx_active_minus1, + H264ModificationOfPicNum* ref_list_mods); + + // Parse prediction weight table (see spec). + Result ParsePredWeightTable(const H264SPS& sps, H264SliceHeader* shdr); + + // Parse weighting factors (see spec). + Result ParseWeightingFactors(int num_ref_idx_active_minus1, + int chroma_array_type, + int luma_log2_weight_denom, + int chroma_log2_weight_denom, + H264WeightingFactors* w_facts); + + // Parse decoded reference picture marking information (see spec). + Result ParseDecRefPicMarking(H264SliceHeader* shdr); + + // Pointer to the current NALU in the stream. + const uint8_t* stream_; + + // Bytes left in the stream after the current NALU. + off_t bytes_left_; + + H264BitReader br_; + + // PPSes and SPSes stored for future reference. + typedef std::map SPSById; + typedef std::map PPSById; + SPSById active_SPSes_; + PPSById active_PPSes_; + + // Ranges of encrypted bytes in the buffer passed to + // SetEncryptedStream(). + Ranges encrypted_ranges_; + + DISALLOW_COPY_AND_ASSIGN(H264Parser); + }; + +} // namespace media + +#endif // MEDIA_FILTERS_H264_PARSER_H_ diff --git a/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/H264/h264_poc.h b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/H264/h264_poc.h new file mode 100755 index 00000000..a83990d1 --- /dev/null +++ b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/H264/h264_poc.h @@ -0,0 +1,45 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef MEDIA_VIDEO_H264_POC_H_ +#define MEDIA_VIDEO_H264_POC_H_ + +#include +#include "macros.h" + +using namespace std; + +namespace media { + + struct H264SPS; + struct H264SliceHeader; + + class MEDIA_EXPORT H264POC { + public: + H264POC(); + ~H264POC(); + + // Compute the picture order count for a slice, storing the result into + // |*pic_order_cnt|. + bool ComputePicOrderCnt( + const H264SPS* sps, + const H264SliceHeader& slice_hdr, + int32_t* pic_order_cnt); + + // Reset computation state. It's best (although not strictly required) to call + // this after a seek. + void Reset(); + + private: + int32_t ref_pic_order_cnt_msb_; + int32_t ref_pic_order_cnt_lsb_; + int32_t prev_frame_num_; + int32_t prev_frame_num_offset_; + + DISALLOW_COPY_AND_ASSIGN(H264POC); + }; + +} // namespace media + +#endif // MEDIA_VIDEO_H264_POC_H_ diff --git a/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/H264/macros.h b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/H264/macros.h new file mode 100755 index 00000000..3570ae9e --- /dev/null +++ b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/H264/macros.h @@ -0,0 +1,100 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file contains macros and macro-like constructs (e.g., templates) that +// are commonly used throughout Chromium source. (It may also contain things +// that are closely related to things that are commonly used that belong in this +// file.) + +#ifndef BASE_MACROS_H_ +#define BASE_MACROS_H_ + +#include // For size_t. + +// Put this in the declarations for a class to be uncopyable. +#define DISALLOW_COPY(TypeName) \ +TypeName(const TypeName&) = delete + +// Put this in the declarations for a class to be unassignable. +#define DISALLOW_ASSIGN(TypeName) \ +void operator=(const TypeName&) = delete + +// A macro to disallow the copy constructor and operator= functions. +// This should be used in the private: declarations for a class. +#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ +TypeName(const TypeName&) = delete; \ +void operator=(const TypeName&) = delete + +// A macro to disallow all the implicit constructors, namely the +// default constructor, copy constructor and operator= functions. +// +// This should be used in the private: declarations for a class +// that wants to prevent anyone from instantiating it. This is +// especially useful for classes containing only static methods. +#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ +TypeName() = delete; \ +DISALLOW_COPY_AND_ASSIGN(TypeName) + +// The arraysize(arr) macro returns the # of elements in an array arr. The +// expression is a compile-time constant, and therefore can be used in defining +// new arrays, for example. If you use arraysize on a pointer by mistake, you +// will get a compile-time error. For the technical details, refer to +// http://blogs.msdn.com/b/the1/archive/2004/05/07/128242.aspx. + +// This template function declaration is used in defining arraysize. +// Note that the function doesn't need an implementation, as we only +// use its type. +template char (&ArraySizeHelper(T (&array)[N]))[N]; +#define arraysize(array) (sizeof(ArraySizeHelper(array))) + +// Used to explicitly mark the return value of a function as unused. If you are +// really sure you don't want to do anything with the return value of a function +// that has been marked WARN_UNUSED_RESULT, wrap it with this. Example: +// +// std::unique_ptr my_var = ...; +// if (TakeOwnership(my_var.get()) == SUCCESS) +// ignore_result(my_var.release()); +// +template +inline void ignore_result(const T&) { +} + +// The following enum should be used only as a constructor argument to indicate +// that the variable has static storage class, and that the constructor should +// do nothing to its state. It indicates to the reader that it is legal to +// declare a static instance of the class, provided the constructor is given +// the base::LINKER_INITIALIZED argument. Normally, it is unsafe to declare a +// static variable that has a constructor or a destructor because invocation +// order is undefined. However, IF the type can be initialized by filling with +// zeroes (which the loader does for static variables), AND the destructor also +// does nothing to the storage, AND there are no virtual methods, then a +// constructor declared as +// explicit MyClass(base::LinkerInitialized x) {} +// and invoked as +// static MyClass my_variable_name(base::LINKER_INITIALIZED); +namespace base { + enum LinkerInitialized { LINKER_INITIALIZED }; + + // Use these to declare and define a static local variable (static T;) so that + // it is leaked so that its destructors are not called at exit. If you need + // thread-safe initialization, use base/lazy_instance.h instead. +#define CR_DEFINE_STATIC_LOCAL(type, name, arguments) \ +static type& name = *new type arguments + +} // base + +#define MEDIA_EXPORT + +#include +#include "Util/logger.h" +using namespace ZL::Util; + +#define DCHECK(x) if(!(x)) { ErrorL << "DCHECK " << #x < (y))) { ErrorL << "DCHECK_GT:" << #x << #y << endl; } +#define DCHECK_GE(x,y) if(!((x) >= (y))) { ErrorL << "DCHECK_GE:" << #x << #y << endl; } +#define DCHECK_LT(x,y) if(!((x) < (y))) { ErrorL << "DCHECK_LT:" << #x << #y << endl; } +#define NOTREACHED() ErrorL << "NOTREACHED" << endl; + + +#endif // BASE_MACROS_H_ diff --git a/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/H264/ranges.h b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/H264/ranges.h new file mode 100755 index 00000000..ab89b5f4 --- /dev/null +++ b/bin_lib/windows/ZLMediaKit/include/ZLMediaKit/H264/ranges.h @@ -0,0 +1,154 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef MEDIA_BASE_RANGES_H_ +#define MEDIA_BASE_RANGES_H_ + +#include +#include + +#include +#include +#include + +using namespace std; + +namespace media { + + // Ranges allows holding an ordered list of ranges of [start,end) intervals. + // The canonical example use-case is holding the list of ranges of buffered + // bytes or times in a