-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add subscriber active/inactive events
- Loading branch information
Showing
9 changed files
with
216 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,115 @@ | ||
namespace Dolby.Millicast | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
using System.Globalization; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
using Newtonsoft.Json.Linq; | ||
|
||
public partial class SimulcastInfo | ||
{ | ||
[JsonProperty("active")] | ||
public SimulcastData[] Active { get; set; } | ||
|
||
[JsonProperty("inactive")] | ||
public SimulcastData[] Inactive { get; set; } | ||
|
||
[JsonProperty("layers")] | ||
public Layer[] Layers { get; set; } | ||
} | ||
namespace Dolby.Millicast { | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public partial class SimulcastData | ||
{ | ||
[JsonProperty("id")] | ||
public string Id { get; set; } | ||
/// <summary> | ||
/// Holds track information for multisource | ||
/// </summary> | ||
public partial class Track { | ||
[JsonProperty("trackId")] | ||
public string TrackId { get; set; } | ||
[JsonProperty("media")] | ||
public string Media { get; set; } | ||
} | ||
|
||
[JsonProperty("simulcastIdx")] | ||
public long SimulcastIdx { get; set; } | ||
public partial class PublisherActiveEvent { | ||
[JsonProperty("streamId")] | ||
public string StreamId { get; set; } | ||
[JsonProperty("sourceId")] | ||
public string SourceId { get; set; } | ||
[JsonProperty("tracks")] | ||
public Track[] Tracks; | ||
} | ||
|
||
[JsonProperty("bitrate")] | ||
public long Bitrate { get; set; } | ||
public partial class PublisherInctiveEvent { | ||
[JsonProperty("streamId")] | ||
public string StreamId { get; set; } | ||
[JsonProperty("sourceId")] | ||
public string SourceId { get; set; } | ||
} | ||
|
||
[JsonProperty("layers")] | ||
public Layer[] Layers { get; set; } | ||
} | ||
public partial class SimulcastInfo { | ||
[JsonProperty("active")] | ||
public SimulcastData[] Active { get; set; } | ||
|
||
[JsonProperty("inactive")] | ||
public SimulcastData[] Inactive { get; set; } | ||
|
||
[JsonProperty("layers")] | ||
public Layer[] Layers { get; set; } | ||
} | ||
|
||
public partial class SimulcastData { | ||
[JsonProperty("id")] | ||
public string Id { get; set; } | ||
|
||
[JsonProperty("simulcastIdx")] | ||
public long SimulcastIdx { get; set; } | ||
|
||
[JsonProperty("bitrate")] | ||
public long Bitrate { get; set; } | ||
|
||
[JsonProperty("layers")] | ||
public Layer[] Layers { get; set; } | ||
} | ||
|
||
public partial class Layer { | ||
[JsonProperty("simulcastIdx")] | ||
public long SimulcastIdx { get; set; } | ||
|
||
public partial class Layer | ||
{ | ||
[JsonProperty("simulcastIdx")] | ||
public long SimulcastIdx { get; set; } | ||
[JsonProperty("spatialLayerId")] | ||
public long SpatialLayerId { get; set; } | ||
|
||
[JsonProperty("spatialLayerId")] | ||
public long SpatialLayerId { get; set; } | ||
[JsonProperty("temporalLayerId")] | ||
public long TemporalLayerId { get; set; } | ||
|
||
[JsonProperty("temporalLayerId")] | ||
public long TemporalLayerId { get; set; } | ||
[JsonProperty("bitrate")] | ||
public long Bitrate { get; set; } | ||
|
||
[JsonProperty("bitrate")] | ||
public long Bitrate { get; set; } | ||
[JsonProperty("encodingId", NullValueHandling = NullValueHandling.Ignore)] | ||
public string EncodingId { get; set; } | ||
} | ||
|
||
[JsonProperty("encodingId", NullValueHandling = NullValueHandling.Ignore)] | ||
public string EncodingId { get; set; } | ||
internal class ServiceResponse { | ||
[JsonProperty("type")] | ||
public string Type { get; set; } | ||
[JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)] | ||
public string Name { get; set; } | ||
[JsonProperty("data", NullValueHandling = NullValueHandling.Ignore)] | ||
public JToken Data { get; set; } | ||
[JsonProperty("transId", NullValueHandling = NullValueHandling.Ignore)] | ||
public string TransactionId { get; set; } | ||
} | ||
|
||
internal class LayerEvent { | ||
[JsonProperty("medias")] | ||
public Dictionary<string, SimulcastInfo> Medias; | ||
} | ||
|
||
internal class DataContainer { | ||
public static SimulcastInfo ParseSimulcastLayers(JToken payload) { | ||
var simulcastData = payload.ToObject<LayerEvent>(); | ||
if (!simulcastData.Medias.ContainsKey("0")) { | ||
Debug.LogError("Invalid payload for simulcast layers event received"); | ||
return null; | ||
} | ||
return simulcastData.Medias["0"]; | ||
} | ||
public class DataContainer | ||
{ | ||
public static SimulcastInfo ParseSimulcastLayers(object mediaData) | ||
{ | ||
var jsonObject = mediaData as JObject; | ||
var simulcastData = jsonObject.SelectToken("0").ToString(); | ||
SimulcastInfo info = JsonConvert.DeserializeObject<SimulcastInfo>(simulcastData); | ||
return info; | ||
} | ||
|
||
public static int ParseViewerCount(JToken payload) { | ||
return payload["viewercount"].ToObject<int>(); | ||
} | ||
|
||
public static PublisherActiveEvent ParsePublisherActiveEvent(JToken payload) { | ||
return payload.ToObject<PublisherActiveEvent>(); | ||
} | ||
|
||
public static PublisherInctiveEvent ParsePublisherInactiveEvent(JToken payload) { | ||
return payload.ToObject<PublisherInctiveEvent>(); | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.