<div dir="ltr">After trying to use strings instead of arrays of chars, I realised that asdcp functions receive as parameters pointers to chars, so the only members that could be strings would be pklfile and maybe path (since the vlc_path2uri also takes as parameters pointers to char). So I think there is no point in changing that, it would make the code even more tangled...<div>
<div class="gmail_extra"><br><div class="gmail_quote">2013/6/28 Rémi Denis-Courmont <span dir="ltr"><<a href="mailto:remi@remlab.net" target="_blank">remi@remlab.net</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Tue, 25 Jun 2013 16:59:11 +0200, Simona-Marinela Prodea<br>
<<a href="mailto:simona.marinela.prodea@gmail.com">simona.marinela.prodea@gmail.com</a>> wrote:<br>
> +//! DCP Structure<br>
> +/*! This structure stores the most important information about the DCP<br>
*/<br>
> +struct dcp_t<br>
<br>
</div>class is a lot cleaner for non-POD.<br>
<div class="im"><br>
> +{<br>
> +    char *path;             /*!< Path to DCP directory */<br>
> +    char *assetmapURI;      /*!< ASSETMAP XML file URI *<br>
</div><div class="im">> +    char *cplfileURI;       /*!< CPL XML file URI */<br>
> +    char *pklfile;          /*!< PKL XML file name */<br>
> +    char *videofile;        /*!< Video file name */<br>
> +    char *audiofile;        /*!< Audio file name */<br>
<br>
</div>And string objects similarly are simpler than character arrays.<br>
<br>
(...)<br>
<div><div class="h5"><br>
> +struct demux_sys_t<br>
> +{<br>
> +    /* ASDCP Picture Essence Type */<br>
> +    EssenceType_t PictureEssType;<br>
> +<br>
> +    /* ASDCP Video MXF Reader */<br>
> +    union<br>
> +    {<br>
> +        /* JPEG2000 essence type */<br>
> +        JP2K::MXFReader *p_PicMXFReader;<br>
> +<br>
> +        /* JPEG2000 stereoscopic essence type */<br>
> +        JP2K::MXFSReader *p_PicMXFSReader;<br>
> +<br>
> +        /* MPEG2 essence type */<br>
> +        MPEG2::MXFReader *p_VideoMXFReader;<br>
> +    };<br>
> +<br>
> +    /* ASDCP Picture Descriptor */<br>
> +    union<br>
> +    {<br>
> +        /* JPEG2000 and JPEG2000 stereoscopic essence types */<br>
> +        JP2K::PictureDescriptor *p_PicDesc;<br>
> +<br>
> +        /* MPEG2 essence type */<br>
> +        MPEG2::VideoDescriptor *p_VideoDesc;<br>
> +    };<br>
> +<br>
> +    /* ASDCP Audio MXF Reader */<br>
> +    PCM::MXFReader *p_AudioMXFReader;<br>
> +<br>
> +    /* ASDCP Audio Descriptor */<br>
> +    PCM::AudioDescriptor *p_AudioDesc;<br>
> +<br>
> +    /* elementary streams */<br>
> +    es_out_t *p_out;<br>
> +    es_out_id_t *p_video_es;<br>
> +    es_out_id_t *p_audio_es;<br>
> +<br>
> +    /* DCP object */<br>
> +    dcp_t *p_dcp;<br>
> +<br>
> +    /* current frame number */<br>
> +    uint32_t frame_no;<br>
> +<br>
> +    /* frame rate */<br>
> +    double frame_rate;<br>
<br>
</div></div>Please store the frame rate as a fraction. Otherwise, rounding errors<br>
_will_ occur.<br>
<div class="im"><br>
<br>
<br>
> +static int Open( vlc_object_t *obj )<br>
> +{<br>
> +    demux_t *p_demux = ( demux_t* ) obj;<br>
> +    demux_sys_t *p_sys = NULL;<br>
> +    es_format_t video_format, audio_format;<br>
> +    vlc_fourcc_t fcc;<br>
> +    int retval;<br>
> +<br>
> +    msg_Dbg( p_demux, "opening DCP access-demux module" );<br>
<br>
</div>Don't spam the logs.<br>
<div class="im"><br>
> +<br>
> +    if( !p_demux->psz_file )<br>
> +    {<br>
> +        freeMem( p_demux );<br>
<br>
</div>WTF?<br>
<div><div class="h5"><br>
> +        return VLC_EGENERIC;<br>
> +    }<br>
> +<br>
> +    /* handle the DCP directory, saving the paths for audio and video<br>
> file, returning error if unsuccessful */<br>
> +    if( ( retval = dcpInit( p_demux ) ) )<br>
> +    {<br>
> +        freeMem( p_demux );<br>
> +        return retval;<br>
> +    }<br>
> +<br>
> +    p_sys = p_demux->p_sys;<br>
> +<br>
> +    /***************************************************<br>
> +     ***************** open video file *****************<br>
> +     ***************************************************/<br>
> +    EssenceType( p_sys->p_dcp->videofile, p_sys->PictureEssType );<br>
> +<br>
> +    switch( p_sys->PictureEssType )<br>
> +    {<br>
> +        case ESS_UNKNOWN:<br>
> +            msg_Err( p_demux, "The file %s is not a supported AS_DCP<br>
> essence container", p_sys->p_dcp->videofile);<br>
> +            freeMem( p_demux );<br>
> +            return VLC_EGENERIC;<br>
> +        case ESS_JPEG_2000:<br>
> +        {<br>
> +            fcc = VLC_FOURCC( 'J', 'P', '2', 'K' );<br>
> +            JP2K::MXFReader *p_PicMXFReader = p_sys->p_PicMXFReader =<br>
new<br>
> ( std::nothrow ) JP2K::MXFReader();<br>
> +            JP2K::PictureDescriptor *p_PicDesc = p_sys->p_PicDesc = new<br>
(<br>
> std::nothrow ) JP2K::PictureDescriptor();<br>
> +<br>
> +            if( !p_PicMXFReader || !p_PicDesc )<br>
> +            {<br>
> +                msg_Err( p_demux, "Could not alloc object for handling<br>
> mxf" );<br>
> +                freeMem( p_demux );<br>
> +                return VLC_ENOMEM;<br>
> +            }<br>
> +            Result_t result = p_PicMXFReader->OpenRead(<br>
> p_sys->p_dcp->videofile );<br>
> +            if( ASDCP_SUCCESS( result ) )<br>
> +                msg_Dbg( p_demux, "file  %s was successfully opened<br>
with<br>
> asdcp", p_sys->p_dcp->videofile );<br>
> +            else<br>
> +            {<br>
> +                msg_Err( p_demux, "File %s could not be opened with<br>
> asdcp", p_sys->p_dcp->videofile );<br>
> +                freeMem( p_demux );<br>
> +                return VLC_EGENERIC;<br>
> +            }<br>
> +<br>
> +            p_PicMXFReader->FillPictureDescriptor( *p_PicDesc );<br>
> +<br>
> +            es_format_Init( &video_format, VIDEO_ES, fcc );<br>
> +            fillVideoFmt( &video_format.video, p_PicDesc->StoredWidth,<br>
> p_PicDesc->StoredHeight, p_PicDesc->EditRate.Numerator,<br>
> p_PicDesc->EditRate.Denominator );<br>
> +<br>
> +            p_sys->p_PicMXFReader = p_PicMXFReader;<br>
> +            p_sys->p_PicDesc = p_PicDesc;<br>
> +            p_sys->frame_no = 0;<br>
> +            if( p_PicDesc->EditRate.Denominator != 0 )<br>
> +                p_sys->frame_rate = p_PicDesc->EditRate.Numerator /<br>
> p_PicDesc->EditRate.Denominator;<br>
> +            p_sys->frames_total = p_PicDesc->ContainerDuration;<br>
> +<br>
> +            break;<br>
> +        }<br>
> +        case ESS_JPEG_2000_S:<br>
> +        {<br>
> +            fcc = VLC_FOURCC( 'J', 'P', '2', 'K' );<br>
> +            JP2K::MXFSReader *p_PicMXFSReader = p_sys->p_PicMXFSReader<br>
=<br>
> new ( std::nothrow ) JP2K::MXFSReader();<br>
> +            JP2K::PictureDescriptor *p_PicDesc = p_sys->p_PicDesc = new<br>
(<br>
> std::nothrow ) JP2K::PictureDescriptor();<br>
> +<br>
> +            if( !p_PicMXFSReader || !p_PicDesc )<br>
> +            {<br>
> +                msg_Err( p_demux, "Could not alloc object for handling<br>
> mxf" );<br>
> +                freeMem( p_demux );<br>
> +                return VLC_ENOMEM;<br>
> +            }<br>
> +<br>
> +            Result_t result = p_PicMXFSReader->OpenRead(<br>
> p_sys->p_dcp->videofile );<br>
> +            if( ASDCP_SUCCESS( result ) )<br>
> +                msg_Dbg( p_demux, "file  %s was successfully opened<br>
with<br>
> asdcp", p_sys->p_dcp->videofile );<br>
> +            else<br>
> +            {<br>
> +                msg_Err( p_demux, "File %s could not be opened with<br>
> asdcp", p_sys->p_dcp->videofile );<br>
> +                freeMem( p_demux );<br>
> +                return VLC_EGENERIC;<br>
> +            }<br>
> +<br>
> +            p_PicMXFSReader->FillPictureDescriptor( *p_PicDesc );<br>
> +<br>
> +            es_format_Init( &video_format, VIDEO_ES, fcc );<br>
> +            fillVideoFmt( &video_format.video, p_PicDesc->StoredWidth,<br>
> p_PicDesc->StoredHeight, p_PicDesc->EditRate.Numerator,<br>
> p_PicDesc->EditRate.Denominator );<br>
> +<br>
> +            p_sys->p_PicMXFSReader = p_PicMXFSReader;<br>
> +            p_sys->p_PicDesc = p_PicDesc;<br>
> +            p_sys->frame_no = 0;<br>
> +            if( p_PicDesc->EditRate.Denominator != 0 )<br>
> +                p_sys->frame_rate = p_PicDesc->EditRate.Numerator /<br>
> p_PicDesc->EditRate.Denominator;<br>
> +            p_sys->frames_total = p_PicDesc->ContainerDuration;<br>
> +<br>
> +            break;<br>
> +        }<br>
> +        case ESS_MPEG2_VES:<br>
> +        {<br>
> +            fcc = VLC_FOURCC( 'm', 'p', 'g', 'v' );<br>
> +            MPEG2::MXFReader *p_VideoMXFReader =<br>
p_sys->p_VideoMXFReader<br>
> = new ( std::nothrow ) MPEG2::MXFReader();<br>
> +            MPEG2::VideoDescriptor *p_VideoDesc = p_sys->p_VideoDesc =<br>
> new ( std::nothrow ) MPEG2::VideoDescriptor();<br>
> +<br>
> +            if( !p_VideoMXFReader || !p_VideoDesc )<br>
> +            {<br>
> +                msg_Err( p_demux, "Could not alloc object for handling<br>
> mxf" );<br>
> +                freeMem( p_demux );<br>
> +                return VLC_ENOMEM;<br>
> +            }<br>
> +<br>
> +            Result_t result = p_VideoMXFReader->OpenRead(<br>
> p_sys->p_dcp->videofile );<br>
> +            if( ASDCP_SUCCESS( result ) )<br>
> +                msg_Dbg( p_demux, "file  %s was successfully opened<br>
with<br>
> asdcp", p_sys->p_dcp->videofile );<br>
> +            else<br>
> +            {<br>
> +                msg_Err( p_demux, "File %s could not be opened with<br>
> asdcp", p_sys->p_dcp->videofile );<br>
> +                freeMem( p_demux );<br>
> +                return VLC_EGENERIC;<br>
> +            }<br>
> +<br>
> +            p_VideoMXFReader->FillVideoDescriptor( *p_VideoDesc );<br>
> +<br>
> +            es_format_Init( &video_format, VIDEO_ES, fcc );<br>
> +            fillVideoFmt( &video_format.video,<br>
p_VideoDesc->StoredWidth,<br>
> p_VideoDesc->StoredHeight, p_VideoDesc->EditRate.Numerator,<br>
> p_VideoDesc->EditRate.Denominator );<br>
> +<br>
> +            p_sys->p_VideoMXFReader = p_VideoMXFReader;<br>
> +            p_sys->p_VideoDesc = p_VideoDesc;<br>
> +            p_sys->frame_no = 0;<br>
> +            if( p_VideoDesc->EditRate.Denominator != 0 )<br>
> +                p_sys->frame_rate = p_VideoDesc->EditRate.Numerator /<br>
> p_VideoDesc->EditRate.Denominator;<br>
> +            p_sys->frames_total = p_VideoDesc->ContainerDuration;<br>
> +<br>
> +            break;<br>
> +        }<br>
> +        default:<br>
> +            msg_Err( p_demux, "Unrecognized video format" );<br>
> +            freeMem( p_demux );<br>
> +            return VLC_EGENERIC;<br>
> +    }<br>
> +<br>
> +    if( ( p_sys->p_video_es = es_out_Add( p_demux->out, &video_format )<br>
)<br>
> == NULL )<br>
> +    {<br>
> +        msg_Err( p_demux, "Failed to add video es" );<br>
> +        freeMem( p_demux );<br>
> +        return VLC_EGENERIC;<br>
> +    }<br>
> +<br>
> +    /***************************************************<br>
> +     ***************** open audio file *****************<br>
> +     ***************************************************/<br>
> +    EssenceType_t AudioEssType;<br>
> +    EssenceType( p_sys->p_dcp->audiofile, AudioEssType );<br>
> +    switch( AudioEssType )<br>
> +    {<br>
> +        case ESS_UNKNOWN:<br>
> +            msg_Err( p_demux, "The file %s is not a supported AS_DCP<br>
> essence container", p_sys->p_dcp->audiofile );<br>
> +            freeMem( p_demux );<br>
> +            return VLC_EGENERIC;<br>
> +        case ESS_PCM_24b_48k:<br>
> +        case ESS_PCM_24b_96k:<br>
> +            fcc = VLC_FOURCC( 's', '2', '4', 'l' );<br>
> +            break;<br>
> +        default:<br>
> +            msg_Err( p_demux, "Unrecognized audio format" );<br>
> +            freeMem( p_demux );<br>
> +            return VLC_EGENERIC;<br>
> +    }<br>
> +<br>
> +    PCM::MXFReader *p_AudioMXFReader = p_sys->p_AudioMXFReader = new (<br>
> std::nothrow ) PCM::MXFReader();<br>
> +    PCM::AudioDescriptor *p_AudioDesc = p_sys->p_AudioDesc = new (<br>
> std::nothrow ) PCM::AudioDescriptor();<br>
> +<br>
> +    if( !p_AudioMXFReader || !p_AudioDesc )<br>
> +    {<br>
> +        msg_Err( p_demux, "Could not alloc object for handling mxf" );<br>
> +        freeMem( p_demux );<br>
> +        return VLC_ENOMEM;<br>
> +    }<br>
> +<br>
> +    Result_t result = p_AudioMXFReader->OpenRead(<br>
p_sys->p_dcp->audiofile<br>
> );<br>
> +    if( ASDCP_SUCCESS( result ) )<br>
> +        msg_Dbg( p_demux, "File  %s was successfully opened with<br>
asdcp",<br>
> p_sys->p_dcp->audiofile );<br>
> +    else<br>
> +    {<br>
> +        msg_Err( p_demux, "File %s could not be opened with asdcp",<br>
> p_sys->p_dcp->audiofile );<br>
> +        freeMem( p_demux );<br>
> +        return VLC_EGENERIC;<br>
> +    }<br>
> +<br>
> +    p_AudioMXFReader->FillAudioDescriptor( *p_AudioDesc );<br>
> +<br>
> +    es_format_Init( &audio_format, AUDIO_ES, fcc );<br>
> +    if( p_AudioDesc->AudioSamplingRate.Denominator != 0 )<br>
> +        audio_format.audio.i_rate =<br>
> p_AudioDesc->AudioSamplingRate.Numerator /<br>
> p_AudioDesc->AudioSamplingRate.Denominator;<br>
> +    audio_format.audio.i_bitspersample = p_AudioDesc->QuantizationBits;<br>
> +    audio_format.audio.i_blockalign = p_AudioDesc->BlockAlign;<br>
> +    audio_format.audio.i_channels = p_AudioDesc->ChannelCount;<br>
> +<br>
> +    p_sys->p_AudioMXFReader = p_AudioMXFReader;<br>
> +    p_sys->p_AudioDesc = p_AudioDesc;<br>
> +<br>
> +<br>
> +    if( ( p_sys->p_audio_es = es_out_Add( p_demux->out, &audio_format )<br>
)<br>
> == NULL )<br>
> +    {<br>
> +        msg_Err( p_demux, "Failed to add audio es" );<br>
> +        freeMem( p_demux );<br>
> +        return VLC_EGENERIC;<br>
> +    }<br>
> +<br>
> +    p_sys->p_out = p_demux->out;<br>
> +    p_demux->pf_demux = Demux;<br>
> +    p_demux->pf_control = Control;<br>
> +    p_demux->p_sys = p_sys;<br>
> +<br>
> +    return VLC_SUCCESS;<br>
> +}<br>
> +<br>
> +static void Close( vlc_object_t *obj )<br>
> +{<br>
> +    demux_t *p_demux = ( demux_t* ) obj;<br>
> +<br>
> +    msg_Dbg( p_demux, "closing DCP access-demux module" );<br>
<br>
</div></div>No spam.<br>
<div class="im HOEnZb"><br>
> +    freeMem( p_demux );<br>
> +}<br>
> +<br>
<br>
</div><span class="HOEnZb"><font color="#888888">--<br>
Rémi Denis-Courmont<br>
Sent from my collocated server<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
vlc-devel mailing list<br>
To unsubscribe or modify your subscription options:<br>
<a href="http://mailman.videolan.org/listinfo/vlc-devel" target="_blank">http://mailman.videolan.org/listinfo/vlc-devel</a><br>
</div></div></blockquote></div><br></div></div></div>