示例#1
0
        /// <summary>
        /// RecordingStream constructor.
        /// </summary>
        /// <param name="inner">Inner stream that it will record.</param>
        /// <param name="size">
        /// The amount of bytes that will be recorded. Will throw if more bytes are read/written from underlying stream.
        /// Ignored if <paramref name="inner"/> is not seekable.
        /// </param>
        /// <param name="recordingType">Type of the recorder: read recorder or write recorder.</param>
        private RecordingStream(Stream inner, long?size, RecordingType recordingType)
        {
            _inner         = inner;
            _recordingType = recordingType;

            // Immediately throw if a given stream does not support the mode we expected.
            // This is quite important, because otherwise the current instance will return false for both 'CanRead' and 'CanWrite'
            // and the stream that is neither readable nor writable is consider to be a disposed stream by some API (like Stream.CopyTo).
            if (recordingType == RecordingType.Read && !inner.CanRead)
            {
                throw new ArgumentException($"Failed to create RecordingStream instance with {recordingType} mode, but a given stream is not readable.");
            }

            if (recordingType == RecordingType.Write && !inner.CanWrite)
            {
                throw new ArgumentException($"Failed to create RecordingStream instance with {recordingType} mode, but a given stream is not writable.");
            }

            if (recordingType == RecordingType.Read && inner.CanSeek && size != null)
            {
                _capacity      = size;
                _recordedBytes = new byte[size.Value];
                _memoryStream  = new MemoryStream(_recordedBytes);
            }
            else
            {
                // If the inner stream is not seekable, create a backing expandable memory stream
                // and do not validate length against _capacity.
                _memoryStream = new MemoryStream();
            }
        }
 private static IEnumerable <string> GetRecordingTypeLabels()
 {
     for (RecordingType type = 0; type < RecordingType.MAX; type++)
     {
         yield return(type.ToString());
     }
 }
        private void AddExisting(
            string title,
            int trackNum,
            Song song,
            Artist artist,
            Album album,
            int recordingID,
            RecordingType recordingType = RecordingType.Standard)
        {
            Recording simpleRecording = new Recording()
            {
                Id            = recordingID,
                Filename      = "",
                RecordingType = recordingType,
                Title         = title,
                Artist        = artist,
                Song          = song,
                Album         = album,
                TrackNumber   = trackNum,
                DiscNumber    = 1,
                Weight        = -1.0
            };

            song.Recordings.Add(simpleRecording);
            artist.Recordings.Add(simpleRecording);

            Recordings.Add(simpleRecording);

            album.Recordings.Add(simpleRecording);
        }
        public void UpdateRecordingType(IEnumerable <Recording> recordings, RecordingType newRecordingType)
        {
            foreach (Recording recording in recordings)
            {
                recording.RecordingType = newRecordingType;
            }

            db.SaveChanges();
        }
        public SeriesRecording(XmlElement node) : base(node)
        {
            foreach (XmlElement propertyNode in node.ChildNodes)
            {
                switch (propertyNode.Name)
                {
                case "id":
                    this._Id = ParseLong(propertyNode.InnerText);
                    continue;

                case "epgId":
                    this._EpgId = ParseLong(propertyNode.InnerText);
                    continue;

                case "channelId":
                    this._ChannelId = ParseLong(propertyNode.InnerText);
                    continue;

                case "seriesId":
                    this._SeriesId = propertyNode.InnerText;
                    continue;

                case "seasonNumber":
                    this._SeasonNumber = ParseInt(propertyNode.InnerText);
                    continue;

                case "type":
                    this._Type = (RecordingType)StringEnum.Parse(typeof(RecordingType), propertyNode.InnerText);
                    continue;

                case "createDate":
                    this._CreateDate = ParseLong(propertyNode.InnerText);
                    continue;

                case "updateDate":
                    this._UpdateDate = ParseLong(propertyNode.InnerText);
                    continue;

                case "excludedSeasons":
                    this._ExcludedSeasons = new List <IntegerValue>();
                    foreach (XmlElement arrayNode in propertyNode.ChildNodes)
                    {
                        this._ExcludedSeasons.Add(ObjectFactory.Create <IntegerValue>(arrayNode));
                    }
                    continue;
                }
            }
        }
示例#6
0
        public static string ToLabel(this RecordingType recordingType)
        {
            switch (recordingType)
            {
            case RecordingType.Standard: return("");

            case RecordingType.Alternate: return("🎙️");

            case RecordingType.Acoustic: return("🔌");

            case RecordingType.Live: return("🎤");

            default:
                Console.WriteLine($"Unexpected RecordingType: {recordingType}");
                goto case RecordingType.Standard;
            }
        }
示例#7
0
	public string ScreenShotName(int width, int height, RecordingType recordingType) {
		string name = "";

		if (recordingType == RecordingType.screenshot) {
			name = string.Format ("{0}/screenshots/screen_{1}x{2}_{3}.png", 
		                     Application.dataPath, 
		                     width, height, 
		                     System.DateTime.Now.ToString ("yyyy-MM-dd_HH-mm-ss"));
		}
		else if (recordingType == RecordingType.continuousVideo) {
			name = string.Format ("{0}/screen_{1}x{2}_{3}.png", 
			                      exp.PNGRecordingPath, //change to path variable? 
			                      width, height, 
			                      numFrames);

			numFrames++;
		}

		return name;
	}
        private Song AddSimple(
            string title,
            int trackNum,
            Artist artist,
            Album album,
            int songID,
            int recordingID,
            RecordingType recordingType = RecordingType.Standard)
        {
            Song simpleSong = new Song()
            {
                Id     = songID,
                Title  = title,
                Weight = -1.0
            };

            Songs.Add(simpleSong);

            Recording simpleRecording = new Recording()
            {
                Id            = recordingID,
                Filename      = "",
                Title         = title,
                RecordingType = recordingType,
                Artist        = artist,
                Song          = simpleSong,
                Album         = album,
                TrackNumber   = trackNum,
                DiscNumber    = 1,
                Weight        = -1.0
            };

            simpleSong.Recordings.Add(simpleRecording);
            artist.Recordings.Add(simpleRecording);

            Recordings.Add(simpleRecording);

            album.Recordings.Add(simpleRecording);

            return(simpleSong);
        }
示例#9
0
        public Recording(XmlElement node) : base(node)
        {
            foreach (XmlElement propertyNode in node.ChildNodes)
            {
                switch (propertyNode.Name)
                {
                case "id":
                    this._Id = ParseLong(propertyNode.InnerText);
                    continue;

                case "status":
                    this._Status = (RecordingStatus)StringEnum.Parse(typeof(RecordingStatus), propertyNode.InnerText);
                    continue;

                case "assetId":
                    this._AssetId = ParseLong(propertyNode.InnerText);
                    continue;

                case "type":
                    this._Type = (RecordingType)StringEnum.Parse(typeof(RecordingType), propertyNode.InnerText);
                    continue;

                case "viewableUntilDate":
                    this._ViewableUntilDate = ParseLong(propertyNode.InnerText);
                    continue;

                case "isProtected":
                    this._IsProtected = ParseBool(propertyNode.InnerText);
                    continue;

                case "createDate":
                    this._CreateDate = ParseLong(propertyNode.InnerText);
                    continue;

                case "updateDate":
                    this._UpdateDate = ParseLong(propertyNode.InnerText);
                    continue;
                }
            }
        }
示例#10
0
	//despite waiting for the end of frame, this coroutine will be started every fixed update, resulting in an image for every fixedupdate call. which is good, because video will have a constant framerate, whereas the game will not.
	IEnumerator TakeScreenshot(RecordingType recordingType){
		// We should only read the screen buffer after rendering is complete

		yield return new WaitForEndOfFrame();
		
		// Create a texture the size of the screen, RGB24 format
		int width = Screen.width;
		int height = Screen.height;
		Texture2D tex = new Texture2D(width, height, TextureFormat.RGB24, false);
		
		// Read screen contents into the texture
		tex.ReadPixels(new Rect(0, 0, width, height), 0, 0);
		tex.Apply();
		
		// Encode texture into PNG
		byte[] bytes = tex.EncodeToPNG();
		Destroy(tex);
		
		// For testing purposes, also write to a file in the project folder
		string filename = ScreenShotName(width, height, recordingType);
		System.IO.File.WriteAllBytes(filename, bytes);

		yield return null;
	}
示例#11
0
        public async Task StartPlaybackAsync(string sessionId, HttpResponse outgoingResponse, RecordingType mode = RecordingType.FilePersisted)
        {
            var id = Guid.NewGuid().ToString();
            ModifiableRecordSession session;

            if (mode == RecordingType.InMemory)
            {
                if (!InMemorySessions.TryGetValue(sessionId, out session))
                {
                    throw new HttpException(HttpStatusCode.BadRequest, $"There is no in-memory session with id {sessionId} available for playback retrieval.");
                }
                session.SourceRecordingId = sessionId;
            }
            else
            {
                var path = GetRecordingPath(sessionId);

                if (!File.Exists(path))
                {
                    throw new TestRecordingMismatchException($"Recording file path {path} does not exist.");
                }

                using var stream = System.IO.File.OpenRead(path);
                using var doc    = await JsonDocument.ParseAsync(stream).ConfigureAwait(false);

                session = new ModifiableRecordSession(RecordSession.Deserialize(doc.RootElement))
                {
                    Path = path
                };
            }

            if (!PlaybackSessions.TryAdd(id, session))
            {
                throw new HttpException(HttpStatusCode.InternalServerError, $"Unexpectedly failed to add new playback session under id {id}.");
            }

            outgoingResponse.Headers.Add("x-recording-id", id);


            var json = JsonSerializer.Serialize(session.Session.Variables);

            outgoingResponse.Headers.Add("Content-Type", "application/json");

            // Write to the response
            await outgoingResponse.WriteAsync(json);
        }