Merge branch 'development' into LTS_development

This commit is contained in:
Thulinma 2017-03-07 17:07:05 +01:00
commit 8b62c1c664
5 changed files with 57 additions and 5 deletions

View file

@ -243,8 +243,10 @@ install(
########################################
add_custom_command(TARGET mist
POST_BUILD
COMMAND mkdir -p ${BINARY_DIR}/mist
COMMAND cp ${libHeaders} ${BINARY_DIR}/mist
COMMAND ${CMAKE_COMMAND}
ARGS -E make_directory ${BINARY_DIR}/mist
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_if_different ${libHeaders} ${BINARY_DIR}/mist
DEPENDS ${libHeaders}
)
@ -438,10 +440,10 @@ endif(DOXYGEN_FOUND)
if (CMAKE_CROSSCOMPILING)
set(RUNA "1")
else()
try_run(RUNA RUNB ${BINARY_DIR}/CMakeTmp ${SOURCE_DIR}/src/sourcery.cpp)
try_run(RUNA RUNB ${BINARY_DIR}/CMakeTmp ${SOURCE_DIR}/src/sourcery.cpp )
endif()
if("${RUNA}" EQUAL "0")
if("${RUNA}" EQUAL "2")
message("Not cross compiling - building sourcery")
add_executable(sourcery
src/sourcery.cpp

View file

@ -1,9 +1,11 @@
/// \file flv_tag.cpp
/// Holds all code for the FLV namespace.
#include "defines.h"
#include "rtmpchunks.h"
#include "flv_tag.h"
#include "timing.h"
#include "util.h"
#include <stdio.h> //for Tag::FileLoader
#include <unistd.h> //for Tag::FileLoader
#include <fcntl.h> //for Tag::FileLoader
@ -52,6 +54,45 @@ bool FLV::is_header(char * header) {
return true;
} //FLV::is_header
/// Helper function that can quickly skip through a file looking for a particular tag type
bool FLV::seekToTagType(FILE * f, uint8_t t){
long long startPos = Util::ftell(f);
DONTEVEN_MSG("Starting seek at %lld", startPos);
char buf[4];
if (fread(buf, 4, 1, f) != 1){return false;}
while (!feof(f) && !ferror(f)){
switch (buf[0]){
case 0x09:
case 0x08:
case 0x12:
{
if (t == buf[0]){
if (fseek(f, -4, SEEK_CUR)){
WARN_MSG("Could not seek back in FLV stream!");
}
INSANE_MSG("Found tag of type %u at %lld", t, Util::ftell(f));
return true;
}
long len = (buf[1] << 16) | (buf[2] << 8) | buf[3];
if (fseek(f, len+11, SEEK_CUR)){
WARN_MSG("Could not seek forward in FLV stream!");
}else{
DONTEVEN_MSG("Seeking %ld+4 bytes forward, now at %lld", len+11, Util::ftell(f));
}
if (fread(buf, 4, 1, f) != 1){return false;}
}
break;
default:
WARN_MSG("Invalid FLV tag detected! Aborting search.");
if (fseek(f, -4, SEEK_CUR)){
WARN_MSG("Could not seek back in FLV stream!");
}
return false;
}
}
}
/// True if this media type requires init data.
/// Will always return false if the tag type is not 0x08 or 0x09.
/// Returns true for H263, AVC (H264), AAC.

View file

@ -24,6 +24,9 @@ namespace FLV {
bool check_header(char * header); ///< Checks a FLV Header for validness.
bool is_header(char * header); ///< Checks the first 3 bytes for the string "FLV".
/// Helper function that can quickly skip through a file looking for a particular tag type
bool seekToTagType(FILE * f, uint8_t type);
/// This class is used to hold, work with and get information about a single FLV tag.
class Tag {
public:

View file

@ -103,6 +103,12 @@ namespace Mist {
void inputFLV::getNext(bool smart) {
long long int lastBytePos = Util::ftell(inFile);
if (selectedTracks.size() == 1){
uint8_t targetTag = 0x08;
if (selectedTracks.count(1)){targetTag = 0x09;}
if (selectedTracks.count(3)){targetTag = 0x12;}
FLV::seekToTagType(inFile, targetTag);
}
while (!feof(inFile) && !FLV::Parse_Error){
if (tmpTag.FileLoader(inFile)){
if ( !selectedTracks.count(tmpTag.getTrackID())){

View file

@ -8,7 +8,7 @@
int main(int argc, char* argv[]){
if (argc < 4) {
std::cerr << "Usage: " << argv[0] << " <inputFile> <variableName> <outputFile>" << std::endl;
return 1;
return 2;
}
std::ofstream tmp(argv[3]);
//begin the first line