This commit is contained in:
Isaac Connor 2021-10-07 12:37:03 -04:00
parent 7079516e09
commit 614750963b
2 changed files with 18 additions and 20 deletions

View File

@ -2537,7 +2537,7 @@ int Monitor::Capture() {
if (packet->codec_type == AVMEDIA_TYPE_VIDEO) { if (packet->codec_type == AVMEDIA_TYPE_VIDEO) {
packet->packet.stream_index = video_stream_id; // Convert to packetQueue's index packet->packet.stream_index = video_stream_id; // Convert to packetQueue's index
if (video_fifo) { if (video_fifo) {
if ( packet->keyframe ) { if (packet->keyframe) {
// avcodec strips out important nals that describe the stream and // avcodec strips out important nals that describe the stream and
// stick them in extradata. Need to send them along with keyframes // stick them in extradata. Need to send them along with keyframes
AVStream *stream = camera->getVideoStream(); AVStream *stream = camera->getVideoStream();

View File

@ -49,45 +49,43 @@ RemoteCamera::RemoteCamera(
mNeedAuth(false), mNeedAuth(false),
mAuthenticator(nullptr) mAuthenticator(nullptr)
{ {
if ( path[0] != '/' ) if (path[0] != '/')
path = '/'+path; path = '/'+path;
} }
RemoteCamera::~RemoteCamera() { RemoteCamera::~RemoteCamera() {
if ( hp != nullptr ) { if (hp != nullptr) {
freeaddrinfo(hp); freeaddrinfo(hp);
hp = nullptr; hp = nullptr;
} }
if ( mAuthenticator ) { if (mAuthenticator) {
delete mAuthenticator; delete mAuthenticator;
mAuthenticator = nullptr; mAuthenticator = nullptr;
} }
} }
void RemoteCamera::Initialise() { void RemoteCamera::Initialise() {
if( protocol.empty() ) if (protocol.empty())
Fatal( "No protocol specified for remote camera" ); Fatal("No protocol specified for remote camera");
if( host.empty() ) if (host.empty())
Fatal( "No host specified for remote camera" ); Fatal("No host specified for remote camera");
if ( port.empty() ) if (port.empty())
Fatal("No port specified for remote camera"); Fatal("No port specified for remote camera");
//if( path.empty() )
//Fatal( "No path specified for remote camera" );
// Cache as much as we can to speed things up // Cache as much as we can to speed things up
std::string::size_type authIndex = host.rfind( '@' ); std::string::size_type authIndex = host.rfind('@');
if ( authIndex != std::string::npos ) { if (authIndex != std::string::npos) {
auth = host.substr( 0, authIndex ); auth = host.substr(0, authIndex);
host.erase( 0, authIndex+1 ); host.erase(0, authIndex+1);
auth64 = Base64Encode(auth); auth64 = Base64Encode(auth);
authIndex = auth.rfind( ':' ); authIndex = auth.rfind(':');
username = auth.substr(0,authIndex); username = auth.substr(0,authIndex);
password = auth.substr( authIndex+1, auth.length() ); password = auth.substr(authIndex+1, auth.length());
} }
mNeedAuth = false; mNeedAuth = false;
@ -99,13 +97,13 @@ void RemoteCamera::Initialise() {
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;
int ret = getaddrinfo(host.c_str(), port.c_str(), &hints, &hp); int ret = getaddrinfo(host.c_str(), port.c_str(), &hints, &hp);
if ( ret != 0 ) { if (ret != 0) {
Error( "Can't getaddrinfo(%s port %s): %s", host.c_str(), port.c_str(), gai_strerror(ret) ); Error("Can't getaddrinfo(%s port %s): %s", host.c_str(), port.c_str(), gai_strerror(ret));
return; return;
} }
struct addrinfo *p = nullptr; struct addrinfo *p = nullptr;
int addr_count = 0; int addr_count = 0;
for ( p = hp; p != nullptr; p = p->ai_next ) { for (p = hp; p != nullptr; p = p->ai_next) {
addr_count++; addr_count++;
} }
Debug(1, "%d addresses returned", addr_count); Debug(1, "%d addresses returned", addr_count);