pByte Utility::ToString(const std::vector<byte> vctr)
{
- pByte array = pByte(new byte[vctr.size()]);
+ pByte str = pByte(new byte[vctr.size()]);
for(int i = 0; i < vctr.size(); i++)
{
- array[i] = vctr.at(i);
+ str[i] = vctr.at(i);
}
- return array;
+ return str;
}
void Utility::AddRange(std::vector<byte>& vctr, const byte* str)
BluRayOutput::BluRayOutput(std::string arg_path, TimeSpan arg_chapterLen)
{
-/** not modefied
- path = arg_path;
chapterLen = arg_chapterLen;
- boost::filesystem::path full_path(boost::filesystem::initial_path<boost::filesystem::path>());
- if(boost::filesystem::exists(full_path))
- boost::filesystem::remove(full_path);
- boost::filesystem::create_directory(full_path);
- boost::filesystem::create_directory(full_path / "BDMV");
- boost::filesystem::create_directory(full_path / "BDMV" / "AUXDATA");
- boost::filesystem::create_directory(full_path / "BDMV" / "BACKUP");
- boost::filesystem::create_directory(full_path / "BDMV" / "BACKUP" / "BDJO");
- boost::filesystem::create_directory(full_path / "BDMV" / "BACKUP" / "CLIPINF");
- boost::filesystem::create_directory(full_path / "BDMV" / "BACKUP" / "PLAYLIST");
- boost::filesystem::create_directory(full_path / "BDMV" / "BDJO");
- boost::filesystem::create_directory(full_path / "BDMV" / "CLIPINF");
- boost::filesystem::create_directory(full_path / "BDMV" / "JAR");
- boost::filesystem::create_directory(full_path / "BDMV" / "META");
- boost::filesystem::create_directory(full_path / "BDMV" / "PLAYLIST");
- boost::filesystem::create_directory(full_path / "BDMV" / "STREAM");
- boost::filesystem::create_directory(full_path / "CERTIFICATE");
- boost::filesystem::create_directory(full_path / "CERTIFICATE" / "BACKUP");
-
- std::ofstream file_index_bdmv(full_path / "BDMV/index.bdmv");
+ path = arg_path;
+ if(boost::filesystem::exists(path))
+ boost::filesystem::remove(path);
+ boost::filesystem::create_directories(path);
+ boost::filesystem::create_directories(path / "BDMV");
+ boost::filesystem::create_directories(path / "BDMV" / "AUXDATA");
+ boost::filesystem::create_directories(path / "BDMV" / "BACKUP");
+ boost::filesystem::create_directories(path / "BDMV" / "BACKUP" / "BDJO");
+ boost::filesystem::create_directories(path / "BDMV" / "BACKUP" / "CLIPINF");
+ boost::filesystem::create_directories(path / "BDMV" / "BACKUP" / "PLAYLIST");
+ boost::filesystem::create_directories(path / "BDMV" / "BDJO");
+ boost::filesystem::create_directories(path / "BDMV" / "CLIPINF");
+ boost::filesystem::create_directories(path / "BDMV" / "JAR");
+ boost::filesystem::create_directories(path / "BDMV" / "META");
+ boost::filesystem::create_directories(path / "BDMV" / "PLAYLIST");
+ boost::filesystem::create_directories(path / "BDMV" / "STREAM");
+ boost::filesystem::create_directories(path / "CERTIFICATE");
+ boost::filesystem::create_directories(path / "CERTIFICATE" / "BACKUP");
+
+ std::string file_name;
+ file_name = path.string() + "/BDMV/index.bdmv";
+ std::ofstream file_index_bdmv(file_name.data());
file_index_bdmv << index_bdmv;
- std::ofstream file_index_bdmv_backup(full_path / "BDMV/BACKUP/index.bdmv");
+ file_name = path.string() + "/BDMV/BACKUP/index.bdmv";
+ std::ofstream file_index_bdmv_backup(file_name.data());
file_index_bdmv_backup << index_bdmv;
- std::ofstream file_movieobject_bdmv(full_path / "BDMV/MovieObject.bdmv");
+ file_name = path.string() + "/BDMV/MovieObject.bdmv";
+ std::ofstream file_movieobject_bdmv(file_name.data());
file_movieobject_bdmv << MovieObject_bdmv;
- std::ofstream file_movieobject_bdmv_backup(full_path / "BDMV/BACKUP/MovieObject.bdmv");
+ file_name = path.string() + "/BDMV/BACKUP/MovieObject.bdmv";
+ std::ofstream file_movieobject_bdmv_backup(file_name.data());
file_movieobject_bdmv_backup << MovieObject_bdmv;
-**/
}
void BluRayOutput::Author(std::vector<EpElement>& EpInfo, std::vector<StreamInfo>& sis, UInt32 numOfSourcePackets)
{
-/**
- List<ushort> Pids = new List<ushort>();
- List<byte[]> StreamCodingInfos = new List<byte[]>();
- List<byte[]> AudioEntries = new List<byte[]>();
- List<byte[]> AudioAttributes = new List<byte[]>();
- List<byte[]> PgEntries = new List<byte[]>();
- List<byte[]> PgAttributes = new List<byte[]>();
- byte[] VideoEntry = null;
- byte[] VideoAttribute = null;
- ElementaryStreamTypes VideoType = ElementaryStreamTypes.INVALID;
- foreach(StreamInfo si in sis)
- {
- switch (si.StreamType)
- {
- case ElementaryStreamTypes.AUDIO_STREAM_AC3:
- case ElementaryStreamTypes.AUDIO_STREAM_AC3_PLUS:
- case ElementaryStreamTypes.AUDIO_STREAM_AC3_TRUE_HD:
- case ElementaryStreamTypes.AUDIO_STREAM_DTS:
- case ElementaryStreamTypes.AUDIO_STREAM_DTS_HD:
- case ElementaryStreamTypes.AUDIO_STREAM_DTS_HD_MASTER_AUDIO:
- case ElementaryStreamTypes.AUDIO_STREAM_LPCM:
- case ElementaryStreamTypes.AUDIO_STREAM_MPEG1:
- case ElementaryStreamTypes.AUDIO_STREAM_MPEG2:
- byte[] AudioEntry = BuildStreamEntry(si.ElementaryPID);
- byte[] AudioAttribute = BuildAudioStreamAttributes((byte)si.StreamType,si.AudioPresentationType,si.SamplingFrequency);
- AudioEntries.Add(AudioEntry);
- AudioAttributes.Add(AudioAttribute);
- byte[] AudioCodingInfo = BuildAudioStreamCodingInfo(si.StreamType, si.AudioPresentationType, si.SamplingFrequency);
- Pids.Add(si.ElementaryPID);
- StreamCodingInfos.Add(AudioCodingInfo);
- break;
- case ElementaryStreamTypes.VIDEO_STREAM_H264:
- case ElementaryStreamTypes.VIDEO_STREAM_MPEG1:
- case ElementaryStreamTypes.VIDEO_STREAM_MPEG2:
- case ElementaryStreamTypes.VIDEO_STREAM_VC1:
- VideoType = si.StreamType;
- VideoEntry = BuildStreamEntry(si.ElementaryPID);
- VideoAttribute = BuildVideoStreamAttributes((byte)si.StreamType,si.VideoFormat,si.FrameRate);
- byte[] VideoCodingInfo = BuildVideoStreamCodingInfo(si.StreamType, si.VideoFormat, si.FrameRate, si.AspectRatio);
- Pids.Add(si.ElementaryPID);
- StreamCodingInfos.Add(VideoCodingInfo);
- break;
- case ElementaryStreamTypes.PRESENTATION_GRAPHICS_STREAM:
- byte[] PgEntry = BuildStreamEntry(si.ElementaryPID);
- PgEntries.Add(PgEntry);
- PgAttributes.Add(PgStreamAttributes);
- byte[] PgCodingInfo = BuildPgStreamCodingInfo();
- Pids.Add(si.ElementaryPID);
- StreamCodingInfos.Add(PgCodingInfo);
- break;
- }
+ std::vector<ushort> Pids;
+ std::vector<pByte> StreamCodingInfos;
+ std::vector<pByte> AudioEntries;
+ std::vector<pByte> AudioAttributes;
+ std::vector<pByte> PgEntries;
+ std::vector<pByte> PgAttributes;
+ pByte VideoEntry;
+ pByte VideoAttribute;
+ pByte VideoCodingInfo;
+ pByte AudioEntry;
+ pByte AudioAttribute;
+ pByte AudioCodingInfo;
+ pByte PgEntry;
+ pByte PgAttribute;
+ pByte PgCodingInfo;
+ ElementaryStreamTypes VideoType = INVALID;
+ for(int i = 0; i < sis.size(); i++)
+ {
+ StreamInfo si = sis.at(i);
+ switch (si.GetElementaryStreamTypes())
+ {
+ case AUDIO_STREAM_AC3:
+ case AUDIO_STREAM_AC3_PLUS:
+ case AUDIO_STREAM_AC3_TRUE_HD:
+ case AUDIO_STREAM_DTS:
+ case AUDIO_STREAM_DTS_HD:
+ case AUDIO_STREAM_DTS_HD_MASTER_AUDIO:
+ case AUDIO_STREAM_LPCM:
+ case AUDIO_STREAM_MPEG1:
+ case AUDIO_STREAM_MPEG2:
+ AudioEntry = BuildStreamEntry(si.GetElementaryPID());
+ AudioAttribute = BuildAudioStreamAttributes(
+ (byte)si.GetElementaryStreamTypes(), si.GetAudioPresentationType(), si.GetSamplingFrequency());
+ AudioEntries.push_back(AudioEntry);
+ AudioAttributes.push_back(AudioAttribute);
+ AudioCodingInfo = BuildAudioStreamCodingInfo(
+ si.GetElementaryStreamTypes(), si.GetAudioPresentationType(), si.GetSamplingFrequency());
+ Pids.push_back(si.GetElementaryPID());
+ StreamCodingInfos.push_back(AudioCodingInfo);
+ break;
+ case VIDEO_STREAM_H264:
+ case VIDEO_STREAM_MPEG1:
+ case VIDEO_STREAM_MPEG2:
+ case VIDEO_STREAM_VC1:
+ VideoType = si.GetElementaryStreamTypes();
+ VideoEntry = BuildStreamEntry(si.GetElementaryPID());
+ VideoAttribute = BuildVideoStreamAttributes(
+ (byte)si.GetElementaryStreamTypes(), si.GetVideoFormat(), si.GetFrameRate());
+ VideoCodingInfo = BuildVideoStreamCodingInfo(
+ si.GetElementaryStreamTypes(), si.GetVideoFormat(), si.GetFrameRate(), si.GetAspectRatio());
+ Pids.push_back(si.GetElementaryPID());
+ StreamCodingInfos.push_back(VideoCodingInfo);
+ break;
+ case PRESENTATION_GRAPHICS_STREAM:
+ PgEntry = BuildStreamEntry(si.GetElementaryPID());
+ PgEntries.push_back(PgEntry);
+ pByte pgsa = pByte(new byte[6]);
+ memcpy(pgsa.get(), &PgStreamAttributes[0], sizeof(PgStreamAttributes));
+ PgAttributes.push_back(pgsa);
+ PgCodingInfo = BuildPgStreamCodingInfo();
+ Pids.push_back(si.GetElementaryPID());
+ StreamCodingInfos.push_back(PgCodingInfo);
+ break;
+ }
}
- byte[][] PlayItems = new byte[1][];
- UInt32 Start = (UInt32)((EpInfo[0].PTS >> 1) & 0xffffffff);
- UInt32 End = (UInt32)((EpInfo[EpInfo.Length - 1].PTS >> 1) & 0xffffffff);
- UInt32 Interval = ((UInt32)(chapterLen.TotalMinutes)) * 2700000;
- byte[] StnTable = BuildStnTable(VideoEntry, VideoAttribute, AudioEntries.ToString(), AudioAttributes.ToString(), PgEntries.ToString(), PgAttributes.ToString());
- PlayItems[0] = BuildFirstPlayItem(0, Start, End, StnTable);
- byte[] PlayList = BuildPlayList(PlayItems);
- byte[] PlayListMark = BuildFirstPlayMarks(Start, End, Interval);
- byte[] mlps = Build_mlps(PlayList, PlayListMark);
- File.WriteAllBytes(Path.Combine(path, @"BDMV\PLAYLIST\00000.mpls"), mlps);
- File.Copy(Path.Combine(path, @"BDMV\PLAYLIST\00000.mpls"), Path.Combine(path, @"BDMV\BACKUP\PLAYLIST\00000.mpls"),true);
-
- byte[] ClipInfo = BuildClipInfo(numOfSourcePackets,EpInfo);
- byte[] SequenceInfo = BuildSequenceInfo(Start, End);
- byte[] ProgramInf = BuildProgramInfo(Pids.ToString(), StreamCodingInfos.ToString());
- byte[] EpMap = BuildEpMap(EpInfo);
- byte[] CPI = BuildCpi(EpMap);
- byte[] clpi = Build_clpi(ClipInfo, SequenceInfo, ProgramInf, CPI);
- File.WriteAllBytes(Path.Combine(path, @"BDMV\CLIPINF\00001.clpi"), clpi);
- File.Copy(Path.Combine(path, @"BDMV\CLIPINF\00001.clpi"), Path.Combine(path, @"BDMV\BACKUP\CLIPINF\00001.clpi"),true);
-**/
+ std::vector<pByte> PlayItems;
+ UInt32 Start = (UInt32)((EpInfo.at(0).pts_ >> 1) & 0xffffffff);
+ UInt32 End = (UInt32)((EpInfo.at(EpInfo.size() - 1).pts_ >> 1) & 0xffffffff);
+ UInt32 Interval = ((UInt32)(chapterLen.total_seconds() / 60)) * 2700000;
+ pByte StnTable = BuildStnTable( VideoEntry, VideoAttribute,
+ AudioEntries, AudioAttributes, PgEntries, PgAttributes);
+ PlayItems.push_back(BuildFirstPlayItem(0, Start, End, StnTable));
+ pByte PlayList = BuildPlayList(PlayItems);
+ pByte PlayListMark = BuildFirstPlayMarks(Start, End, Interval);
+ pByte mlps = Build_mlps(PlayList, PlayListMark);
+
+ std::string file_name;
+ file_name = path.string() + "/BDMV/PLAYLIST/00000.mpls";
+ std::ofstream file_mlps(file_name.data());
+ file_mlps << mlps.get();
+ file_name = path.string() + "/BDMV/BACKUP/PLAYLIST/00000.mlps";
+ std::ofstream file_mlps_backup(file_name.data());
+ file_mlps_backup << mlps.get();
+
+ pByte ClipInfo = BuildClipInfo(numOfSourcePackets,EpInfo);
+ pByte SequenceInfo = BuildSequenceInfo(Start, End);
+ pByte ProgramInf = BuildProgramInfo(Pids, StreamCodingInfos);
+ pByte EpMap = BuildEpMap(EpInfo);
+ pByte CPI = BuildCpi(EpMap);
+ pByte clpi = Build_clpi(ClipInfo, SequenceInfo, ProgramInf, CPI);
+
+ file_name = path.string() + "/BDMV/CLIPINF/00001.clpi";
+ std::ofstream file_clpi(file_name.data());
+ file_clpi << clpi.get();
+ file_name = path.string() + "/BDMV/BACKUP/CLIPINF/00001.clpi";
+ std::ofstream file_clpi_backup(file_name.data());
+ file_clpi_backup << clpi.get();
+
}
pByte BluRayOutput::BuildStreamEntry(ushort pid)