Exemple #1
0
        public metaframe_avchd[] getmetadata()  //use this with the array type return
        //public List<metaframe_avchd> getmetadata()   //testing a list return, but can't figure out inheritance
        {
            int estimatedframes = (int)(((movielength / 1000000) * framerate) * 1.10);   //change the last number to add some buffer

            totalframes = estimatedframes;
            int framesize = numtags * 5;

            fullmetadata = new metaframe[estimatedframes];
            //for (int i = 1; i< estimatedframes; i++)  //for use with byte array version
            //{
            //    //fullmetadata[i].metaframedata = new byte[framesize];
            //    fullmetadata[i] = new metaframe(framesize);
            //}
            for (int i = 0; i < estimatedframes; i++)   //for use with inptr version  //don't forget to free memory
            {
                fullmetadata[i].frameno      = 0;
                fullmetadata[i].p_flags      = 0;
                fullmetadata[i].p_dur        = 0;
                fullmetadata[i].p_pts        = 0;
                fullmetadata[i].p_dts        = 0;
                fullmetadata[i].p_pos        = 0;
                fullmetadata[i].framedataptr = Marshal.AllocHGlobal(framesize);
            }
            IntPtr test = getmetadata(moviefile, 0, numtags, metalength, estimatedframes, fullmetadata);

            testresult = (String)Marshal.PtrToStringAnsi(test);

            if (string.Compare(testresult, "file_open_error") == 0)
            {
                throw new System.Exception("The Movie File Could Not be Opened");
            }
            if (string.Compare(testresult, "no_stream_info") == 0)
            {
                throw new System.Exception("Could Not Find Stream Information");
            }
            if (string.Compare(testresult, "memory_error") == 0)
            {
                throw new System.Exception("Memory Error");
            }
            if (string.Compare(testresult, "camera_not_supported_error") == 0)
            {
                throw new System.Exception("Camera Not Supported");
            }
            if (string.Compare(testresult, "videostream_not_found_error") == 0)
            {
                throw new System.Exception("Video Stream Not Found");
            }
            if (string.Compare(testresult, "codec_not_found_error") == 0)
            {
                throw new System.Exception("Unsupported Codec");
            }
            if (string.Compare(testresult, "open_codec_error") == 0)
            {
                throw new System.Exception("Could Not Open Codec");
            }

            if (string.Compare(testresult, "metadata_copied") == 0) //check for correct return flag
            {
                testoutput = testresult;                            //need code here to process internal metadata pointers - assuming proper return code
                byte []           temp         = new byte[framesize];
                metaframe_avchd[] resultsarray = new metaframe_avchd[estimatedframes];
                for (int i = 0; i < estimatedframes; i++)   //for use with inptr version  //don't forget to free memory
                {
                    //must marshal ptr to byte array here
                    Marshal.Copy(fullmetadata[i].framedataptr, temp, 0, framesize);
                    resultsarray[i]                = new metaframe_avchd(i, framesize, temp);
                    resultsarray[i].PacketFlags    = fullmetadata[i].p_flags;
                    resultsarray[i].PacketDuration = fullmetadata[i].p_dur;
                    resultsarray[i].PacketPts      = fullmetadata[i].p_pts;
                    resultsarray[i].PacketPos      = fullmetadata[i].p_pos;
                    resultsarray[i].PacketDts      = fullmetadata[i].p_dts;
                    resultsarray[i].PacketDuration = fullmetadata[i].p_dur;
                    if (fullmetadata[i].p_dur != 0)
                    {
                        resultsarray[i].isRealFrame = true;
                    }
                    Marshal.FreeHGlobal(fullmetadata[i].framedataptr);
                }
                return(resultsarray);
                //List<metaframe_avchd> metalist = resultsarray.ToList();
                //return metalist;
            }
            else
            {
                throw new System.Exception("Error Processing AVCHD video file");
            }
        }
Exemple #2
0
        //use this with the array type return
        //public List<metaframe_avchd> getmetadata()   //testing a list return, but can't figure out inheritance
        public metaframe_avchd[] getmetadata()
        {
            int estimatedframes = (int)(((movielength / 1000000) * framerate) * 1.10);   //change the last number to add some buffer
            totalframes = estimatedframes;
            int framesize = numtags * 5;
            fullmetadata = new metaframe[estimatedframes];
            //for (int i = 1; i< estimatedframes; i++)  //for use with byte array version
            //{
            //    //fullmetadata[i].metaframedata = new byte[framesize];
            //    fullmetadata[i] = new metaframe(framesize);
            //}
            for (int i = 0; i < estimatedframes; i++)   //for use with inptr version  //don't forget to free memory
            {
                fullmetadata[i].frameno = 0;
                fullmetadata[i].p_flags = 0;
                fullmetadata[i].p_dur = 0;
                fullmetadata[i].p_pts = 0;
                fullmetadata[i].p_dts = 0;
                fullmetadata[i].p_pos = 0;
                fullmetadata[i].framedataptr = Marshal.AllocHGlobal(framesize);
            }
            IntPtr test = getmetadata(moviefile, 0, numtags, metalength, estimatedframes, fullmetadata);
            testresult = (String)Marshal.PtrToStringAnsi(test);

            if (string.Compare(testresult, "file_open_error") == 0)
            {
                throw new System.Exception("The Movie File Could Not be Opened");
            }
            if (string.Compare(testresult, "no_stream_info") == 0)
            {
                throw new System.Exception("Could Not Find Stream Information");
            }
            if (string.Compare(testresult, "memory_error") == 0)
            {
                throw new System.Exception("Memory Error");
            }
            if (string.Compare(testresult, "camera_not_supported_error") == 0)
            {
                throw new System.Exception("Camera Not Supported");
            }
            if (string.Compare(testresult, "videostream_not_found_error") == 0)
            {
                throw new System.Exception("Video Stream Not Found");
            }
            if (string.Compare(testresult, "codec_not_found_error") == 0)
            {
                throw new System.Exception("Unsupported Codec");
            }
            if (string.Compare(testresult, "open_codec_error") == 0)
            {
                throw new System.Exception("Could Not Open Codec");
            }

            if (string.Compare(testresult, "metadata_copied") == 0)  //check for correct return flag
            {
                testoutput = testresult;    //need code here to process internal metadata pointers - assuming proper return code
                byte [] temp = new byte[framesize];
                metaframe_avchd[] resultsarray = new metaframe_avchd[estimatedframes];
                for (int i = 0; i < estimatedframes; i++)   //for use with inptr version  //don't forget to free memory
                {
                    //must marshal ptr to byte array here
                    Marshal.Copy(fullmetadata[i].framedataptr,temp,0,framesize);
                    resultsarray[i] = new metaframe_avchd(i, framesize, temp);
                    resultsarray[i].PacketFlags = fullmetadata[i].p_flags;
                    resultsarray[i].PacketDuration = fullmetadata[i].p_dur;
                    resultsarray[i].PacketPts = fullmetadata[i].p_pts;
                    resultsarray[i].PacketPos = fullmetadata[i].p_pos;
                    resultsarray[i].PacketDts = fullmetadata[i].p_dts;
                    resultsarray[i].PacketDuration = fullmetadata[i].p_dur;
                    if (fullmetadata[i].p_dur != 0) resultsarray[i].isRealFrame = true;
                    Marshal.FreeHGlobal(fullmetadata[i].framedataptr);

                }
                return resultsarray;
                //List<metaframe_avchd> metalist = resultsarray.ToList();
                //return metalist;
            }
            else
            {
                throw new System.Exception("Error Processing AVCHD video file");
            }
        }