Convert to autotools build system for cleanness (part1).
This commit is contained in:
parent
3ebfe1b693
commit
36e086e0e2
125 changed files with 125 additions and 4475 deletions
64
src/converters/dtsc2flv.cpp
Normal file
64
src/converters/dtsc2flv.cpp
Normal file
|
@ -0,0 +1,64 @@
|
|||
/// \file DTSC2FLV/main.cpp
|
||||
/// Contains the code that will transform any valid DTSC input into valid FLVs.
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include "../../util/flv_tag.h" //FLV support
|
||||
#include "../../util/dtsc.h" //DTSC support
|
||||
#include "../../util/amf.h" //AMF support
|
||||
|
||||
/// Holds all code that converts filetypes to DTSC.
|
||||
namespace Converters{
|
||||
|
||||
/// Reads DTSC from STDIN, outputs FLV to STDOUT.
|
||||
int DTSC2FLV() {
|
||||
FLV::Tag FLV_out; // Temporary storage for outgoing FLV data.
|
||||
DTSC::Stream Strm;
|
||||
std::string inBuffer;
|
||||
char charBuffer[1024*10];
|
||||
unsigned int charCount;
|
||||
bool doneheader = false;
|
||||
|
||||
while (std::cin.good()){
|
||||
std::cin.read(charBuffer, 1024*10);
|
||||
charCount = std::cin.gcount();
|
||||
inBuffer.append(charBuffer, charCount);
|
||||
if (Strm.parsePacket(inBuffer)){
|
||||
if (!doneheader){
|
||||
doneheader = true;
|
||||
std::cout.write(FLV::Header, 13);
|
||||
FLV_out.DTSCMetaInit(Strm);
|
||||
std::cout.write(FLV_out.data, FLV_out.len);
|
||||
if (Strm.metadata.getContentP("video") && Strm.metadata.getContentP("video")->getContentP("init")){
|
||||
FLV_out.DTSCVideoInit(Strm);
|
||||
std::cout.write(FLV_out.data, FLV_out.len);
|
||||
}
|
||||
if (Strm.metadata.getContentP("audio") && Strm.metadata.getContentP("audio")->getContentP("init")){
|
||||
FLV_out.DTSCAudioInit(Strm);
|
||||
std::cout.write(FLV_out.data, FLV_out.len);
|
||||
}
|
||||
}
|
||||
if (FLV_out.DTSCLoader(Strm)){
|
||||
std::cout.write(FLV_out.data, FLV_out.len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::cerr << "Done!" << std::endl;
|
||||
|
||||
return 0;
|
||||
}//FLV2DTSC
|
||||
|
||||
};//Converter namespace
|
||||
|
||||
/// Entry point for DTSC2FLV, simply calls Converters::DTSC2FLV().
|
||||
int main(){
|
||||
return Converters::DTSC2FLV();
|
||||
}//main
|
70
src/converters/flv2dtsc.cpp
Normal file
70
src/converters/flv2dtsc.cpp
Normal file
|
@ -0,0 +1,70 @@
|
|||
/// \file FLV2DTSC/main.cpp
|
||||
/// Contains the code that will transform any valid FLV input into valid DTSC.
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include "../../util/flv_tag.h" //FLV support
|
||||
#include "../../util/dtsc.h" //DTSC support
|
||||
#include "../../util/amf.h" //AMF support
|
||||
|
||||
/// Holds all code that converts filetypes to DTSC.
|
||||
namespace Converters{
|
||||
|
||||
/// Reads FLV from STDIN, outputs DTSC to STDOUT.
|
||||
int FLV2DTSC() {
|
||||
FLV::Tag FLV_in; // Temporary storage for incoming FLV data.
|
||||
DTSC::DTMI meta_out; // Storage for outgoing DTMI header data.
|
||||
DTSC::DTMI pack_out; // Storage for outgoing DTMI data.
|
||||
std::stringstream prebuffer; // Temporary buffer before sending real data
|
||||
bool sending = false;
|
||||
unsigned int counter = 0;
|
||||
|
||||
while (!feof(stdin)){
|
||||
if (FLV_in.FileLoader(stdin)){
|
||||
pack_out = FLV_in.toDTSC(meta_out);
|
||||
if (pack_out.isEmpty()){continue;}
|
||||
if (!sending){
|
||||
counter++;
|
||||
if (counter > 8){
|
||||
sending = true;
|
||||
meta_out.Pack(true);
|
||||
meta_out.packed.replace(0, 4, DTSC::Magic_Header);
|
||||
std::cout << meta_out.packed;
|
||||
std::cout << prebuffer.rdbuf();
|
||||
prebuffer.str("");
|
||||
std::cerr << "Buffer done, starting real-time output..." << std::endl;
|
||||
}else{
|
||||
prebuffer << pack_out.Pack(true);//buffer
|
||||
continue;//don't also write
|
||||
}
|
||||
}
|
||||
std::cout << pack_out.Pack(true);//simply write
|
||||
}
|
||||
}
|
||||
|
||||
// if the FLV input is very short, do output it correctly...
|
||||
if (!sending){
|
||||
std::cerr << "EOF - outputting buffer..." << std::endl;
|
||||
meta_out.Pack(true);
|
||||
meta_out.packed.replace(0, 4, DTSC::Magic_Header);
|
||||
std::cout << meta_out.packed;
|
||||
std::cout << prebuffer.rdbuf();
|
||||
}
|
||||
std::cerr << "Done!" << std::endl;
|
||||
|
||||
return 0;
|
||||
}//FLV2DTSC
|
||||
|
||||
};//Buffer namespace
|
||||
|
||||
/// Entry point for FLV2DTSC, simply calls Converters::FLV2DTSC().
|
||||
int main(){
|
||||
return Converters::FLV2DTSC();
|
||||
}//main
|
Loading…
Add table
Add a link
Reference in a new issue