New file |
| | |
| | | //
|
| | | // H264FramedSource.cpp
|
| | | // FFmpegRTSPServer
|
| | | //
|
| | | // Created by Mina Saad on 9/22/15.
|
| | | // Copyright (c) 2015 Mina Saad. All rights reserved.
|
| | | //
|
| | |
|
| | | #include <sstream>
|
| | | #include "H264FramedSource.h"
|
| | |
|
| | | using namespace MESAI;
|
| | |
|
| | | H264FramedSource * H264FramedSource::createNew(UsageEnvironment& env, const FrameCallbacks& _cbs)
|
| | | {
|
| | | return new H264FramedSource(env, _cbs);
|
| | | }
|
| | |
|
| | | H264FramedSource::H264FramedSource(UsageEnvironment& env, const FrameCallbacks& _cbs)
|
| | | : FramedSource(env), spsBase64(), ppsBase64(), cbs(_cbs)
|
| | | {
|
| | | }
|
| | |
|
| | | H264FramedSource::~H264FramedSource()
|
| | | {
|
| | |
|
| | | }
|
| | |
|
| | | std::string H264FramedSource::getAuxLine() const
|
| | | {
|
| | | std::ostringstream oss;
|
| | | //a=fmtp:96 profile-level-id=420029; packetization-mode=1; sprop-parameter-sets=Z00AHpW4KA9oQAABwgAAV+QB,aO48gA==
|
| | | oss << "a=fmtp:96 profile-level-id=420029; packetization-mode=1; sprop-parameter-sets=" << spsBase64 << "," << ppsBase64 << "\r\n";
|
| | | return oss.str();
|
| | | }
|
| | |
|
| | |
|
| | | void H264FramedSource::doGetNextFrame()
|
| | | {
|
| | | if (!isCurrentlyAwaitingData())
|
| | | return; // we're not ready for the data yet
|
| | |
|
| | | uint8_t* newFrameDataStart = nullptr;
|
| | | size_t newFrameSize = 0;
|
| | |
|
| | | if (cbs.deliverFrameCallback(cbs.args, newFrameDataStart, newFrameSize, fPresentationTime))
|
| | | {
|
| | | if (newFrameDataStart != NULL && newFrameSize > 0)
|
| | | {
|
| | | if (newFrameSize > fMaxSize)
|
| | | {
|
| | | fFrameSize = fMaxSize;
|
| | | fNumTruncatedBytes = newFrameSize - fMaxSize;
|
| | | }
|
| | | else
|
| | | {
|
| | | fFrameSize = newFrameSize;
|
| | | }
|
| | |
|
| | | memcpy(fTo, newFrameDataStart, fFrameSize);
|
| | | }
|
| | | else
|
| | | {
|
| | | fFrameSize = 0;
|
| | | fTo = NULL;
|
| | | handleClosure(this);
|
| | | }
|
| | |
|
| | | cbs.releaseFrameCallback(cbs.args);
|
| | | }
|
| | | else
|
| | | {
|
| | | fFrameSize = 0;
|
| | | }
|
| | |
|
| | | if(fFrameSize > 0)
|
| | | FramedSource::afterGetting(this);
|
| | | }
|