/*
-Copyright (c) 2004-2007, John Hurst
+Copyright (c) 2004-2009, John Hurst
All rights reserved.
Redistribution and use in source and binary forms, with or without
*/
#include "AS_DCP_internal.h"
+#include <iostream>
+#include <iomanip>
//------------------------------------------------------------------------------------------
return RESULT_OK;
}
+//
+std::ostream&
+ASDCP::MPEG2::operator << (std::ostream& strm, const VideoDescriptor& VDesc)
+{
+ strm << " SampleRate: " << VDesc.SampleRate.Numerator << "/" << VDesc.SampleRate.Denominator << std::endl;
+ strm << " FrameLayout: " << (unsigned) VDesc.FrameLayout << std::endl;
+ strm << " StoredWidth: " << (unsigned) VDesc.StoredWidth << std::endl;
+ strm << " StoredHeight: " << (unsigned) VDesc.StoredHeight << std::endl;
+ strm << " AspectRatio: " << VDesc.AspectRatio.Numerator << "/" << VDesc.AspectRatio.Denominator << std::endl;
+ strm << " ComponentDepth: " << (unsigned) VDesc.ComponentDepth << std::endl;
+ strm << " HorizontalSubsmpl: " << (unsigned) VDesc.HorizontalSubsampling << std::endl;
+ strm << " VerticalSubsmpl: " << (unsigned) VDesc.VerticalSubsampling << std::endl;
+ strm << " ColorSiting: " << (unsigned) VDesc.ColorSiting << std::endl;
+ strm << " CodedContentType: " << (unsigned) VDesc.CodedContentType << std::endl;
+ strm << " LowDelay: " << (unsigned) VDesc.LowDelay << std::endl;
+ strm << " BitRate: " << (unsigned) VDesc.BitRate << std::endl;
+ strm << " ProfileAndLevel: " << (unsigned) VDesc.ProfileAndLevel << std::endl;
+ strm << " ContainerDuration: " << (unsigned) VDesc.ContainerDuration << std::endl;
+
+ return strm;
+}
//
void
class ASDCP::MPEG2::MXFReader::h__Reader : public ASDCP::h__Reader
{
ASDCP_NO_COPY_CONSTRUCT(h__Reader);
+ h__Reader();
public:
VideoDescriptor m_VDesc; // video parameter list
- h__Reader() {}
+ h__Reader(const Dictionary& d) : ASDCP::h__Reader(d) {}
~h__Reader() {}
Result_t OpenRead(const char*);
Result_t ReadFrame(ui32_t, FrameBuffer&, AESDecContext*, HMACContext*);
ASDCP::MPEG2::MXFReader::h__Reader::ReadFrame(ui32_t FrameNum, FrameBuffer& FrameBuf,
AESDecContext* Ctx, HMACContext* HMAC)
{
+ assert(m_Dict);
if ( ! m_File.IsOpen() )
return RESULT_INIT;
- Result_t result = ReadEKLVFrame(FrameNum, FrameBuf, Dict::ul(MDD_MPEG2Essence), Ctx, HMAC);
+ Result_t result = ReadEKLVFrame(FrameNum, FrameBuf, m_Dict->ul(MDD_MPEG2Essence), Ctx, HMAC);
if ( ASDCP_FAILURE(result) )
return result;
ASDCP::MPEG2::MXFReader::MXFReader()
{
- m_Reader = new h__Reader;
+ m_Reader = new h__Reader(DefaultCompositeDict());
}
//
class ASDCP::MPEG2::MXFWriter::h__Writer : public ASDCP::h__Writer
{
+ ASDCP_NO_COPY_CONSTRUCT(h__Writer);
+ h__Writer();
+
public:
VideoDescriptor m_VDesc;
ui32_t m_GOPOffset;
byte_t m_EssenceUL[SMPTE_UL_LENGTH];
- ASDCP_NO_COPY_CONSTRUCT(h__Writer);
-
- h__Writer() : m_GOPOffset(0) {
+ h__Writer(const Dictionary& d) : ASDCP::h__Writer(d), m_GOPOffset(0) {
memset(m_EssenceUL, 0, SMPTE_UL_LENGTH);
}
if ( ASDCP_SUCCESS(result) )
{
m_HeaderSize = HeaderSize;
- m_EssenceDescriptor = new MPEG2VideoDescriptor;
+ m_EssenceDescriptor = new MPEG2VideoDescriptor(m_Dict);
result = m_State.Goto_INIT();
}
ASDCP::Result_t
ASDCP::MPEG2::MXFWriter::h__Writer::SetSourceStream(const VideoDescriptor& VDesc)
{
+ assert(m_Dict);
if ( ! m_State.Test_INIT() )
return RESULT_STATE;
Result_t result = MPEG2_VDesc_to_MD(m_VDesc, (MPEG2VideoDescriptor*)m_EssenceDescriptor);
if ( ASDCP_SUCCESS(result) )
- result = WriteMXFHeader(MPEG_PACKAGE_LABEL, UL(Dict::ul(MDD_MPEG2_VESWrapping)),
- PICT_DEF_LABEL, UL(Dict::ul(MDD_PictureDataDef)),
+ result = WriteMXFHeader(MPEG_PACKAGE_LABEL, UL(m_Dict->ul(MDD_MPEG2_VESWrapping)),
+ PICT_DEF_LABEL, UL(m_Dict->ul(MDD_PictureDataDef)),
m_VDesc.EditRate, 24 /* TCFrameRate */);
if ( ASDCP_SUCCESS(result) )
{
- memcpy(m_EssenceUL, Dict::ul(MDD_MPEG2Essence), SMPTE_UL_LENGTH);
+ memcpy(m_EssenceUL, m_Dict->ul(MDD_MPEG2Essence), SMPTE_UL_LENGTH);
m_EssenceUL[SMPTE_UL_LENGTH-1] = 1; // first (and only) essence container
result = m_State.Goto_READY();
}
ASDCP::MPEG2::MXFWriter::OpenWrite(const char* filename, const WriterInfo& Info,
const VideoDescriptor& VDesc, ui32_t HeaderSize)
{
- m_Writer = new h__Writer;
+ if ( Info.LabelSetType == LS_MXF_SMPTE )
+ m_Writer = new h__Writer(DefaultSMPTEDict());
+ else
+ m_Writer = new h__Writer(DefaultInteropDict());
+
m_Writer->m_Info = Info;
Result_t result = m_Writer->OpenWrite(filename, HeaderSize);