Compare commits
2 Commits
sandbox/ma
...
sandbox/ma
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f031dc1731 | ||
|
|
274c641666 |
@@ -13,6 +13,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sample_muxer", "sample_muxe
|
||||
{7B1F12CA-0724-430B-B61A-1D357C912CBA} = {7B1F12CA-0724-430B-B61A-1D357C912CBA}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libwebvtt", "libwebvtt.vcproj", "{9545310B-A6E6-4B42-BB00-655D66B6E3D5}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
@@ -31,6 +33,10 @@ Global
|
||||
{B407561F-1F5E-4798-B9C2-81AB09CFBC16}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{B407561F-1F5E-4798-B9C2-81AB09CFBC16}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{B407561F-1F5E-4798-B9C2-81AB09CFBC16}.Release|Win32.Build.0 = Release|Win32
|
||||
{9545310B-A6E6-4B42-BB00-655D66B6E3D5}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{9545310B-A6E6-4B42-BB00-655D66B6E3D5}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{9545310B-A6E6-4B42-BB00-655D66B6E3D5}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{9545310B-A6E6-4B42-BB00-655D66B6E3D5}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
157
libwebvtt.vcproj
Normal file
157
libwebvtt.vcproj
Normal file
@@ -0,0 +1,157 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="libwebvtt_2008"
|
||||
ProjectGUID="{9545310B-A6E6-4B42-BB00-655D66B6E3D5}"
|
||||
RootNamespace="libwebvtt"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)..\lib\$(SolutionName)\$(ProjectName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(SolutionDir)..\obj\$(SolutionName)\$(ProjectName)\$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
MinimalRebuild="false"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
DebugInformationFormat="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath=".\webvttparser.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\webvttparser.hpp"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
1326
mkvparser.cpp
1326
mkvparser.cpp
File diff suppressed because it is too large
Load Diff
@@ -42,15 +42,6 @@ signed char Unserialize1SInt(IMkvReader*, long long);
|
||||
long UnserializeInt(IMkvReader*, long long pos, long len, long long& result);
|
||||
#endif
|
||||
|
||||
long UnserializeString(IMkvReader*, long long pos, long long size, char*&);
|
||||
|
||||
long ParseElementHeader(
|
||||
IMkvReader* pReader,
|
||||
long long& pos, //consume id and size fields
|
||||
long long stop, //if you know size of element's parent
|
||||
long long& id,
|
||||
long long& size);
|
||||
|
||||
bool Match(IMkvReader*, long long&, unsigned long, long long&);
|
||||
bool Match(IMkvReader*, long long&, unsigned long, char*&);
|
||||
bool Match(IMkvReader*, long long&, unsigned long, unsigned char*&, size_t&);
|
||||
@@ -298,8 +289,6 @@ class Track
|
||||
Track& operator=(const Track&);
|
||||
|
||||
public:
|
||||
enum Type { kVideo = 1, kAudio = 2 };
|
||||
|
||||
Segment* const m_pSegment;
|
||||
const long long m_element_start;
|
||||
const long long m_element_size;
|
||||
@@ -355,7 +344,6 @@ protected:
|
||||
const Info&,
|
||||
long long element_start,
|
||||
long long element_size);
|
||||
|
||||
const Info m_info;
|
||||
|
||||
class EOSBlock : public BlockEntry
|
||||
@@ -380,20 +368,12 @@ class VideoTrack : public Track
|
||||
VideoTrack(const VideoTrack&);
|
||||
VideoTrack& operator=(const VideoTrack&);
|
||||
|
||||
public:
|
||||
VideoTrack(
|
||||
Segment*,
|
||||
const Info&,
|
||||
long long element_start,
|
||||
long long element_size);
|
||||
|
||||
public:
|
||||
static long Parse(
|
||||
Segment*,
|
||||
const Info&,
|
||||
long long element_start,
|
||||
long long element_size,
|
||||
VideoTrack*&);
|
||||
|
||||
long long GetWidth() const;
|
||||
long long GetHeight() const;
|
||||
double GetFrameRate() const;
|
||||
@@ -414,19 +394,12 @@ class AudioTrack : public Track
|
||||
AudioTrack(const AudioTrack&);
|
||||
AudioTrack& operator=(const AudioTrack&);
|
||||
|
||||
public:
|
||||
AudioTrack(
|
||||
Segment*,
|
||||
const Info&,
|
||||
long long element_start,
|
||||
long long element_size);
|
||||
public:
|
||||
static long Parse(
|
||||
Segment*,
|
||||
const Info&,
|
||||
long long element_start,
|
||||
long long element_size,
|
||||
AudioTrack*&);
|
||||
|
||||
double GetSamplingRate() const;
|
||||
long long GetChannels() const;
|
||||
long long GetBitDepth() const;
|
||||
@@ -458,12 +431,7 @@ public:
|
||||
long long size,
|
||||
long long element_start,
|
||||
long long element_size);
|
||||
|
||||
~Tracks();
|
||||
|
||||
long Parse();
|
||||
|
||||
unsigned long GetTracksCount() const;
|
||||
virtual ~Tracks();
|
||||
|
||||
const Track* GetTrackByNumber(unsigned long tn) const;
|
||||
const Track* GetTrackByIndex(unsigned long idx) const;
|
||||
@@ -472,13 +440,15 @@ private:
|
||||
Track** m_trackEntries;
|
||||
Track** m_trackEntriesEnd;
|
||||
|
||||
long ParseTrackEntry(
|
||||
long long payload_start,
|
||||
long long payload_size,
|
||||
void ParseTrackEntry(
|
||||
long long,
|
||||
long long,
|
||||
Track*&,
|
||||
long long element_start,
|
||||
long long element_size,
|
||||
Track*&) const;
|
||||
long long element_size);
|
||||
|
||||
public:
|
||||
unsigned long GetTracksCount() const;
|
||||
};
|
||||
|
||||
|
||||
@@ -503,8 +473,6 @@ public:
|
||||
|
||||
~SegmentInfo();
|
||||
|
||||
long Parse();
|
||||
|
||||
long long GetTimeCodeScale() const;
|
||||
long long GetDuration() const; //scaled
|
||||
const char* GetMuxingAppAsUTF8() const;
|
||||
@@ -541,8 +509,6 @@ public:
|
||||
|
||||
~SeekHead();
|
||||
|
||||
long Parse();
|
||||
|
||||
struct Entry
|
||||
{
|
||||
//the SeekHead entry payload
|
||||
|
||||
49
sample.cpp
49
sample.cpp
@@ -11,7 +11,6 @@
|
||||
|
||||
#include "mkvreader.hpp"
|
||||
#include "mkvparser.hpp"
|
||||
#include <memory>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// Silences these warnings:
|
||||
@@ -84,18 +83,15 @@ int main(int argc, char* argv[])
|
||||
printf("\t\tDoc Type\t\t: %s\n", ebmlHeader.m_docType);
|
||||
printf("\t\tPos\t\t\t: %lld\n", pos);
|
||||
|
||||
typedef mkvparser::Segment seg_t;
|
||||
seg_t* pSegment_;
|
||||
mkvparser::Segment* pSegment;
|
||||
|
||||
long long ret = seg_t::CreateInstance(&reader, pos, pSegment_);
|
||||
long long ret = mkvparser::Segment::CreateInstance(&reader, pos, pSegment);
|
||||
if (ret)
|
||||
{
|
||||
printf("\n Segment::CreateInstance() failed.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
const std::auto_ptr<seg_t> pSegment(pSegment_);
|
||||
|
||||
ret = pSegment->Load();
|
||||
if (ret < 0)
|
||||
{
|
||||
@@ -246,6 +242,7 @@ int main(int argc, char* argv[])
|
||||
if (clusterCount == 0)
|
||||
{
|
||||
printf("\t\tSegment has no clusters.\n");
|
||||
delete pSegment;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -267,7 +264,7 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
printf("\t\tError parsing first block of cluster\n");
|
||||
fflush(stdout);
|
||||
return -1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
while ((pBlockEntry != NULL) && !pBlockEntry->EOS())
|
||||
@@ -276,27 +273,21 @@ int main(int argc, char* argv[])
|
||||
const long long trackNum = pBlock->GetTrackNumber();
|
||||
const unsigned long tn = static_cast<unsigned long>(trackNum);
|
||||
const Track* const pTrack = pTracks->GetTrackByNumber(tn);
|
||||
const long long trackType = pTrack->GetType();
|
||||
const int frameCount = pBlock->GetFrameCount();
|
||||
const long long time_ns = pBlock->GetTime(pCluster);
|
||||
|
||||
if (pTrack == NULL)
|
||||
printf("\t\t\tBlock\t\t:UNKNOWN TRACK TYPE\n");
|
||||
else
|
||||
printf("\t\t\tBlock\t\t:%s,%s,%15lld\n",
|
||||
(trackType == VIDEO_TRACK) ? "V" : "A",
|
||||
pBlock->IsKey() ? "I" : "P",
|
||||
time_ns);
|
||||
|
||||
for (int i = 0; i < frameCount; ++i)
|
||||
{
|
||||
const long long trackType = pTrack->GetType();
|
||||
const int frameCount = pBlock->GetFrameCount();
|
||||
const long long time_ns = pBlock->GetTime(pCluster);
|
||||
|
||||
printf("\t\t\tBlock\t\t:%s,%s,%15lld\n",
|
||||
(trackType == VIDEO_TRACK) ? "V" : "A",
|
||||
pBlock->IsKey() ? "I" : "P",
|
||||
time_ns);
|
||||
|
||||
for (int i = 0; i < frameCount; ++i)
|
||||
{
|
||||
const Block::Frame& theFrame = pBlock->GetFrame(i);
|
||||
const long size = theFrame.len;
|
||||
const long long offset = theFrame.pos;
|
||||
printf("\t\t\t %15ld,%15llx\n", size, offset);
|
||||
}
|
||||
const Block::Frame& theFrame = pBlock->GetFrame(i);
|
||||
const long size = theFrame.len;
|
||||
const long long offset = theFrame.pos;
|
||||
printf("\t\t\t %15ld,%15llx\n", size, offset);
|
||||
}
|
||||
|
||||
status = pCluster->GetNext(pBlockEntry, pBlockEntry);
|
||||
@@ -305,13 +296,15 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
printf("\t\t\tError parsing next block of cluster\n");
|
||||
fflush(stdout);
|
||||
return -1;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
pCluster = pSegment->GetNext(pCluster);
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
done:
|
||||
delete pSegment;
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
23
webvttparser.cpp
Normal file
23
webvttparser.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "webvttparser.hpp"
|
||||
|
||||
namespace WebvttParser
|
||||
{
|
||||
|
||||
IReader::IReader()
|
||||
{
|
||||
}
|
||||
|
||||
IReader::~IReader()
|
||||
{
|
||||
}
|
||||
|
||||
Parser::Parser(IReader* p) :
|
||||
m_pReader(p)
|
||||
{
|
||||
}
|
||||
|
||||
Parser::~Parser()
|
||||
{
|
||||
}
|
||||
|
||||
} //end namespace WebvttParser
|
||||
60
webvttparser.hpp
Normal file
60
webvttparser.hpp
Normal file
@@ -0,0 +1,60 @@
|
||||
#ifndef WEBVTTPARSER_HPP
|
||||
#define WEBVTTPARSER_HPP
|
||||
|
||||
namespace WebvttParser
|
||||
{
|
||||
|
||||
class IReader
|
||||
{
|
||||
protected:
|
||||
IReader();
|
||||
virtual ~IReader();
|
||||
|
||||
public:
|
||||
virtual int Read(char& c) = 0;
|
||||
|
||||
};
|
||||
|
||||
class Parser
|
||||
{
|
||||
private:
|
||||
Parser(const Parser&);
|
||||
Parser& operator=(const Parser&);
|
||||
|
||||
public:
|
||||
Parser(IReader*);
|
||||
~Parser();
|
||||
|
||||
int Parse();
|
||||
|
||||
//need to know kind:
|
||||
// caption, description, metadata, etc
|
||||
// is this a webvtt stream?
|
||||
//
|
||||
//cue identifier
|
||||
//timestamp (or defaults?) + cue settings
|
||||
//payload
|
||||
// preserve each line
|
||||
|
||||
//machine states:
|
||||
// parsing stream id ("webvtt")
|
||||
// parsing file-wide metadata
|
||||
// parsing cue
|
||||
//
|
||||
//within cue:
|
||||
// parsing line
|
||||
// is this a cue identifier or timestamp line?
|
||||
//
|
||||
// parsing cue id
|
||||
// parsing timestamp
|
||||
// parsing lines, looking for end-of-cue
|
||||
|
||||
private:
|
||||
IReader* const m_pReader;
|
||||
|
||||
};
|
||||
|
||||
|
||||
} //end namespace WebvttParser
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user