コード例 #1
0
        public static bool ParseFile(string Path, Options opt)
        {
            bool   result = false;
            string log    = "\r\n";

            try
            {
                FileStream fs = new FileStream(Path, FileMode.Open, FileAccess.Read);
                if (fs != null)
                {
                    long offset = 0;
                    fs.Seek((long)offset, SeekOrigin.Begin);
                    while (offset < fs.Length)
                    {
                        Mp4Box box = Mp4Box.ReadMp4Box(fs);
                        if (box != null)
                        {
                            log += box.ToString() + "\tat offset: " + offset.ToString() + "\r\n";
                            if (box.GetBoxType() != "mdat\0")
                            {
                                log += Mp4Box.GetBoxChildrenString(0, box);
                            }
                            if (((opt.TraceLevel >= Options.LogLevel.Verbose) && (!string.IsNullOrEmpty(opt.TraceFile))) || (opt.ConsoleLevel >= Options.LogLevel.Verbose))
                            {
                                log += Options.DumpHex(box.GetBoxBytes());
                            }
                            offset += box.GetBoxLength();
                            opt.LogInformation(log);
                            log = "\r\n";
                        }
                        else
                        {
                            break;
                        }
                    }
                    fs.Close();
                    result = true;
                }
            }
            catch (Exception ex)
            {
                opt.LogError("ERROR: Exception while parsing the file: " + ex.Message);
            }
            return(result);
        }
コード例 #2
0
        public static string ParseFile(string Path, Options opt, CallBack callback)
        {
            string result = "\r\n";

            try
            {
                FileStream fs = new FileStream(Path, FileMode.Open, FileAccess.Read);
                if (fs != null)
                {
                    long offset = 0;
                    fs.Seek((long)offset, SeekOrigin.Begin);
                    while (offset < fs.Length)
                    {
                        Mp4Box box = Mp4Box.ReadMp4Box(fs);
                        if (box != null)
                        {
                            result += box.ToString() + "\tat offset: " + offset.ToString() + "\r\n";
                            if (box.GetBoxType() != "mdat\0")
                            {
                                result += Mp4Box.GetBoxChildrenString(0, box);
                            }


                            offset += box.GetBoxLength();
                            if (callback != null)
                            {
                                callback(opt, result);
                            }
                            result = "\r\n";
                        }
                        else
                        {
                            break;
                        }
                    }
                    fs.Close();
                }
            }
            catch (Exception ex)
            {
                result += "ERROR: Exception while parsing the file: " + ex.Message;
            }
            return(result);
        }