Exemplo n.º 1
0
        public static void TranscodeFile(string filePath, string outputPath, Dynastream.Fit.Sport resultantSport)
        {
            Console.WriteLine("Transcoding file {0} to {1}..", filePath, outputPath);
            using (var fitFileStream = new FileStream(filePath, FileMode.Open))
                using (var outputFitFileStream = new FileStream(outputPath, FileMode.Create))
                {
                    var decoder = new Dynastream.Fit.Decode();
                    var encoder = new Dynastream.Fit.Encode();
                    using (var transcoder = new Transcoder(decoder, encoder, resultantSport))
                    {
                        encoder.Open(outputFitFileStream);

                        bool status = decoder.IsFIT(fitFileStream) & decoder.CheckIntegrity(fitFileStream);

                        // Process the file
                        if (!status)
                        {
                            throw new ApplicationException(string.Format("Integrity Check Failed {0}", filePath));
                        }
                        else
                        {
                            decoder.Read(fitFileStream);
                        }

                        encoder.Close();
                    }
                }
            Console.WriteLine("Transcoded file {0} to {1}..", filePath, outputPath);
        }
Exemplo n.º 2
0
 internal Transcoder(Dynastream.Fit.Decode decoder, Dynastream.Fit.Encode encoder, Dynastream.Fit.Sport resultantSport)
 {
     this.decoder                      = decoder;
     this.decoder.MesgEvent           += new Dynastream.Fit.MesgEventHandler(this.HandleMessageEvent);
     this.decoder.MesgDefinitionEvent += new Dynastream.Fit.MesgDefinitionEventHandler(this.HandleMessageDefinitionEvent);
     this.encoder                      = encoder;
     this.resultantSport               = resultantSport;
 }