public CAudio(CAudio oldCAudio) { this.AudioCodec = oldCAudio.AudioCodec; this.m_iAudioCodec = oldCAudio.m_iAudioCodec; this.AudioBitRate = oldCAudio.AudioBitRate; this.m_fAudioBitRate = oldCAudio.m_fAudioBitRate; this.Duration = oldCAudio.Duration; this.m_tpDuration = oldCAudio.m_tpDuration; }
public void RemoveAudioFlux(CAudio oldCAudio) { if (oldCAudio == null) { return; } if (this.AudioFlux != null) { if (this.AudioFlux.Contains(oldCAudio)) { this.AudioFlux.Remove(oldCAudio); } } }
public void AddAudioFlux(CAudio newCAudio) { if (newCAudio == null) { return; } if (this.AudioFlux == null) { this.AudioFlux = new System.Collections.ArrayList(); } if (!this.AudioFlux.Contains(newCAudio)) { this.AudioFlux.Add(newCAudio); } }
/** * Parse the current file and load its characteristics. */ public override void loadFileCharacteristics() { byte [] buffer; uint pos; int c; int size; int fcc = 0; uint a_c = 0; uint v_c = 0; int type = 0; int scale = 0; int rate = 0; int length = 0; uint cont = 1; double fps = 0; int readed_bytes = 0; Encoding asciiEncoding = new ASCIIEncoding(); CAudio audioTrack = null; Byte[] scan; //int i; //byte octet; FileStream fileStream; //Read some bytes from the AVI file scan = new byte[15]; try { fileStream = new FileStream(CompleteFileName, FileMode.Open, FileAccess.Read); readed_bytes = fileStream.Read(scan, 0, 12); } catch (Exception e) { Console.WriteLine("ERROR exception : " + e.Message); return; } //Testing if the file is really an AVI file if (!compareString(scan, avi_signature)) { return; } //Looking for AVI data while (cont != 0) { readed_bytes = fileStream.Read(scan, 0, 12); if (readed_bytes == 0) { break; } b2DW(out size, scan, 4); if (size < 4) { size = 4; } for (c = 0; c < 4; c++) { if (compareString(scan, patterns[c])) { break; } } switch (c) { case 0: //header reading if (size > max_allowed_avi_header_size) { return; //header too big } buffer = new byte[size + safe_pad - 4 + 10000]; readed_bytes = fileStream.Read(buffer, 0, size - 4 + 10000); if (readed_bytes == 0) { break; } pos = 76; b2DWi(out fcc, buffer, pos); while (pos < size) { switch (fcc) { case (int)fourcc.FOURCC_strh: b2DW(out type, buffer, pos + 8); b2DW(out scale, buffer, pos + 28); b2DW(out rate, buffer, pos + 32); b2DW(out length, buffer, pos + 40); fps = (double)rate / (double)(scale != 0?scale:0x7FFFFFFF); length = (int)(length / fps); pos += 64; fcc = 0; break; case (int)fourcc.FOURCC_strf: switch (type) { //Found the video case (int)fourcc.FOURCC_vids: VideoFPS = (float)fps; VideoDuration = new TimeSpan(0, 0, length); VideoCodec = (string)codecs[b2DWv(buffer, pos + 24)]; DimensionsX = b2DWv(buffer, pos + 12); DimensionsY = b2DWv(buffer, pos + 16); if (debug == true) { Console.WriteLine("Scale: " + scale); Console.WriteLine("Rate: " + rate); Console.WriteLine("Length: " + length + " s"); Console.WriteLine("FPS: " + fps); Console.WriteLine("X: " + b2DWv(buffer, pos + 12)); Console.WriteLine("Y:" + b2DWv(buffer, pos + 16)); Console.WriteLine("Codec: " + VideoCodec); } //pos+=40; //ARGGGHHH, gros bidouillage!! try { pos += System.UInt32.Parse(((int)(0x1074 - 24 + size - 8830)).ToString()); } catch (Exception e) { Console.WriteLine("CAvi::LoadFileCharacteristics() - parse error " + e.Message); return; } if (pos > size + safe_pad - 4 + 10000) { size = 0; pos = 0; } v_c++; break; case (int)fourcc.FOURCC_auds: //Found the audio //TODO: find the codec!! Phoque! //if(codec == "mp3") audioTrack = new CMp3(); audioTrack.AudioBitRate = rate; audioTrack.nbOfChannels = b2Wv(buffer, pos + 10); audioTrack.Duration = new TimeSpan(0, 0, length); if (debug == true) { Console.WriteLine("rate: " + rate + "Hz"); Console.WriteLine("Speakers: " + b2Wv(buffer, pos + 10)); //TODO : find this gayzou! //Console.WriteLine("Codec: "+ b2Wv(buffer,pos+10)); } AddAudioFlux(audioTrack); a_c++; size = 0; break; } fcc = 0; break; } //Damn it!!! //INSb(ref fcc,buffer,pos); b2DWi(out fcc, buffer, pos); } continue; case 1: //INFO reading /** Let's do it later...*/ case 3: //idx1 processing /**TODO ?? */ cont = 0; break; } fileStream.Seek(size - 4, SeekOrigin.Current); } fileStream.Close(); }