コード例 #1
0
        public void StartRecording()
        {
            System.IO.Stream outputStream = System.IO.File.Open(wavPath, FileMode.Create);
            bWriter     = new BinaryWriter(outputStream);
            audioBuffer = new byte[44100 * 5]; // 44100 sample rate * 10 sek (max time)

            audRecorder = new AudioRecord(AudioSource.Mic,
                                          44100,
                                          ChannelIn.Mono,
                                          Android.Media.Encoding.Pcm16bit,
                                          audioBuffer.Length);

//            long longSampleRate = 44100;
//            int channels = 2;
//            long byteRate = 16*longSampleRate*channels/8;
//
//            long totalAudioLen = audioBuffer.Length;
//            long totalDataLen = totalAudioLen + 36;
//
//            WriteWaveFileHeader(bWriter,
//                totalAudioLen,
//                totalDataLen,
//                longSampleRate,
//                channels,
//                byteRate);

            IsRecording = true;
            audRecorder.StartRecording();

            SaveBinaryAudio(outputStream);
        }
コード例 #2
0
 public void          XML_Carga(string raizW, string raizL, string[] arqs)
 {
     Mensaje_Curto("Carregando arquivos da Web...");
     foreach (string arq in arqs)
     {
         HttpWebRequest   llamadas = (HttpWebRequest)WebRequest.Create(raizW + arq);
         HttpWebResponse  resposta = (HttpWebResponse)llamadas.GetResponse();
         System.IO.Stream txt      = resposta.GetResponseStream();
         StreamWriter     doc      = new StreamWriter(raizL + arq);
         byte[]           buf      = new byte[8192];
         string           lin      = null;
         int con = 1;
         while (con > 0)
         {
             con = txt.Read(buf, 0, buf.Length);
             if (con != 0)
             {
                 lin = System.Text.Encoding.UTF8.GetString(buf, 0, con);
                 doc.WriteLine(lin);
             }
         }
         doc.Close();
         doc.Dispose();
     }
     Mensaje_Curto("Arquivos XML carregados no telefone.");
 }
コード例 #3
0
        /// <summary>
        /// load a stream (maybe from a file) into this snapshot.
        /// </summary>
        /// <param name="r"></param>
        public void load(System.IO.Stream r)
        {
            XmlSerializer s      = new XmlSerializer(typeof(Revision));
            Revision      rev    = null;
            string        branch = null;
            MemoryStream  strm;

            _branches.insert(branch);

            do
            {
                strm = _readBytes(r);
                if (strm != null)
                {
                    rev = s.Deserialize(strm) as Revision;

                    if (rev != null)
                    {
                        _addRevision(rev);
                    }
                }
            }       while(strm != null);

            r.Close();
        }
コード例 #4
0
ファイル: Legacy.cs プロジェクト: gocheap/ShokoServer
        //Common

        /// <summary>
        ///  Return image that is used as support image, images are build-in
        /// </summary>
        /// <param name="name">name of image inside resource</param>
        /// <returns></returns>
        private object GetSupportImageRest(string name)
        {
            System.IO.Stream image = _impl.GetSupportImage(name);
            response = new Nancy.Response();
            response = Response.FromStream(image, "image/png");
            return(response);
        }
コード例 #5
0
ファイル: Legacy.cs プロジェクト: gocheap/ShokoServer
 /// <summary>
 /// Return image with given path
 /// </summary>
 /// <param name="path"></param>
 /// <returns></returns>
 private object GetImageUsingPathRest(string path)
 {
     System.IO.Stream image = _rest.GetImageUsingPath(path);
     response = new Nancy.Response();
     response = Response.FromStream(image, MimeTypes.GetMimeType(path));
     return(response);
 }
コード例 #6
0
ファイル: Legacy.cs プロジェクト: gocheap/ShokoServer
 /// <summary>
 /// Return image that is used as support image, images are build-in with given ratio
 /// </summary>
 /// <param name="name"></param>
 /// <param name="ratio"></param>
 /// <returns></returns>
 private object GetSupportImageRest(string name, string ratio)
 {
     System.IO.Stream image = _rest.GetSupportImage(name, ratio);
     response = new Nancy.Response();
     // This will always be png, so we are ok
     response = Response.FromStream(image, "image/png");
     return(response);
 }
コード例 #7
0
ファイル: Legacy.cs プロジェクト: gocheap/ShokoServer
        /// <summary>
        /// Return thumbnail with given ratio
        /// </summary>
        /// <param name="type"></param>
        /// <param name="id"></param>
        /// <param name="ratio"></param>
        /// <returns></returns>
        private object GetThumbRest(string type, string id, string ratio)
        {
            string contentType;

            System.IO.Stream image = _rest.GetThumb(type, id, ratio, out contentType);
            response = new Nancy.Response();
            response = Response.FromStream(image, contentType);
            return(response);
        }
コード例 #8
0
ファイル: Legacy.cs プロジェクト: gocheap/ShokoServer
        /// <summary>
        /// Return image with given Id type and information if its should be thumb
        /// </summary>
        /// <param name="id"></param>
        /// <param name="type"></param>
        /// <param name="thumb"></param>
        /// <returns></returns>
        private object GetImageRest(string id, string type, bool thumb)
        {
            string contentType;

            System.IO.Stream image = _rest.GetImage(type, id, thumb, out contentType);
            response = new Nancy.Response();
            // This is not always png
            response = Response.FromStream(image, contentType);
            return(response);
        }
コード例 #9
0
        public static string ReadJsonFromInternalStorage(System.IO.Stream fileStream)
        {
            const long bufferLength = 1024 * 1024 * 20;

            byte[] jsonBytes = new byte[bufferLength];

            fileStream.Read(jsonBytes, 0, jsonBytes.Length);

            var json = GetString(jsonBytes);

            return(json);
        }
コード例 #10
0
 public static byte[] ReadFully(System.IO.Stream input)
 {
     byte[] buffer = new byte[16 * 1024];
     using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
     {
         int read;
         while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
         {
             ms.Write(buffer, 0, read);
         }
         return(ms.ToArray());
     }
 }
コード例 #11
0
 void Initialize(Stream stream, System.Action <string> callback, Encoding encoding, int bufferSize)
 {
     if (bufferSize < MIN_BUFFSIZE)
     {
         bufferSize = MIN_BUFFSIZE;
     }
     this.stream   = stream;
     this.callback = callback;
     this.encoding = encoding;
     this.bbuff    = new byte[bufferSize];
     this.cbuff    = new char[encoding.GetMaxCharCount(bufferSize)];
     this.decoder  = this.encoding.GetDecoder();
     this.mtxEof   = new Thr::ManualResetEvent(false);
 }
コード例 #12
0
        /// <summary>
        /// save the current status of this snapshot out to a stream (file?)
        /// </summary>
        /// <param name="w"></param>
        public void save(System.IO.Stream w)
        {
            /* create the snapshot */
            XmlSerializer s = new XmlSerializer(typeof(Revision));

            RevisionIdx.iterator it = this._changesetIdx.begin();
            for (; it != this._changesetIdx.end(); ++it)
            {
                s.Serialize(w, it.value());
                w.Write(MAGIC_BYTES, 0, MAGIC_BYTES.Length);
            }

            w.Flush();
            w.Close();
        }
コード例 #13
0
 private void Init(Process process, Stream stream, UserCallBack callback, Encoding encoding, int bufferSize)
 {
     this.process      = process;
     this.stream       = stream;
     this.encoding     = encoding;
     this.userCallBack = callback;
     this.decoder      = encoding.GetDecoder();
     if (bufferSize < 0x80)
     {
         bufferSize = 0x80;
     }
     this.byteBuffer         = new byte[bufferSize];
     this._maxCharsPerBuffer = encoding.GetMaxCharCount(bufferSize);
     this.charBuffer         = new char[this._maxCharsPerBuffer];
     this.cancelOperation    = false;
     this.eofEvent           = new Thr::ManualResetEvent(false);
     this.sb = null;
     this.bLastCarriageReturn = false;
 }
コード例 #14
0
        protected virtual void Dispose(bool disposing)
        {
            if (this.stream != null)
            {
                if (disposing)
                {
                    this.stream.Close();
                }
                this.stream     = null;
                this.encoding   = null;
                this.decoder    = null;
                this.byteBuffer = null;
                this.charBuffer = null;
            }

            if (this.eofEvent != null)
            {
                this.eofEvent.Close();
                this.eofEvent = null;
            }
        }
コード例 #15
0
 public override ResourceData FromFileToUpdate(System.IO.Stream stream, string extension, ResourceLang currentLang)
 {
     return(FromFile(stream, extension));
 }
コード例 #16
0
        public static void WriteJsonToInternalStorage(System.IO.Stream fileStream, string json)
        {
            var jsonBytes = GetBytes(json);

            fileStream.Write(jsonBytes, 0, jsonBytes.Length);
        }
コード例 #17
0
 public override ResourceData FromFileToAdd(System.IO.Stream stream, string extension, ushort langId, ResourceSource currentSource)
 {
     return(FromFile(stream, extension));
 }