void AVPacket::release() { // @todo - when a AVPacket is not part of a memory pool we need to have a way to cleanly free the memory .. // @todo - ... this is e.g. used in the encoder thread when we add a stop packet, this stop packets needs to be deleted which we do herea if(!memory_pool) { STREAMER_WARNING("warning: trying to refcount an AVPacket which does not have a memory pool! - maybe a stop packet?\n"); STREAMER_WARNING("warning: we are going to delete ourself!\n"); delete this; return; } memory_pool->release(this); }
void AVPacket::addRef(int count) { if(!memory_pool) { STREAMER_WARNING("warning: trying to refcount an AVPacket which does not have a memory pool! - maybe a stop packet?\n"); return; } memory_pool->addRef(this, count); }
void videoencoder_x264_log(void* param, int level, const char* fmt, va_list arg) { return ; // @todo remove char buf[1024 * 8]; vsprintf(buf, fmt, arg); if(level == X264_LOG_ERROR) { STREAMER_ERROR(buf); } else if(level == X264_LOG_WARNING) { STREAMER_WARNING(buf); } else { STREAMER_VERBOSE(buf); } }
bool VideoEncoder::createDecoderConfigurationRecord(AVCDecoderConfigurationRecord& rec) { assert(encoder); int num_nals = 0; x264_nal_t* nals = NULL; x264_encoder_headers(encoder, &nals, &num_nals); if(!nals) { STREAMER_ERROR("error: cannot get encoder headers from x264.\n"); return false; } if(num_nals != 3) { STREAMER_WARNING("warning: we expect number of nals from x264_encoder_headers to be 3.\n"); return false; } int sps_size = nals[0].i_payload; int pps_size = nals[1].i_payload; int sei_size = nals[2].i_payload; uint8_t* sps = nals[0].p_payload + 4; uint8_t* pps = nals[1].p_payload + 4; uint8_t* sei = nals[2].p_payload + 4; rec.configuration_version = 1; rec.avc_profile_indication = sps[1]; rec.profile_compatibility = sps[2]; rec.avc_level_indication = sps[3]; std::copy(sps, sps+(sps_size-4), std::back_inserter(rec.sps)); std::copy(pps, pps+(pps_size-4), std::back_inserter(rec.pps)); std::copy(sei, sei+(sei_size-4), std::back_inserter(rec.sei)); STREAMER_VERBOSE("nals[0].i_payload: %d, sps_size: %d, profile: %d\n", nals[0].i_payload, sps_size, sps[1]); STREAMER_VERBOSE("nals[1].i_payload: %d, pps_size: %d\n", nals[1].i_payload, pps_size); STREAMER_VERBOSE("nals[2].i_payload: %d, sei_size: %d / %ld\n", nals[2].i_payload, sei_size, rec.sei.size()); return true; }
void sighandler(int signum) { STREAMER_WARNING("\nStop!\n"); must_run = false; }