Esempio n. 1
0
        public void GetStreamingUserTimeline()
        {
            StreamingOptions options = new StreamingOptions {
                User = m_user, Follow = "sebatestapi"
            };

            try
            {
                StreamingEndpoint streamingService = new StreamingEndpoint();

                int count = 0;
                foreach (Status status in streamingService.GetStreamingStatus(options))
                {
                    System.Diagnostics.Debug.Write(status);
                    count++;

                    if (count == 1)
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Assert.True(false, Util.ExceptionMessage(ex));
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Merge and return the combination of two streaming options for a same resource.
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public StreamingOptions CombineWith(StreamingOptions other)
 {
     return(new StreamingOptions
     {
         KeepLoaded = other.KeepLoaded || KeepLoaded,
         ForceHighestQuality = other.ForceHighestQuality || ForceHighestQuality,
         LoadImmediately = other.LoadImmediately || LoadImmediately
     });
 }
Esempio n. 3
0
        public void GetStreamingTimelineWithHashtag()
        {
            Thread.Sleep(2000);
            StreamingOptions options = new StreamingOptions {
                Track = "#twitter", User = m_user
            };

            Execute(options);
        }
Esempio n. 4
0
        public void GetStreamingTimelineWithComa()
        {
            Thread.Sleep(2000);
            StreamingOptions options = new StreamingOptions {
                Track = "twitter,facebook", User = m_user
            };

            Execute(options);
        }
Esempio n. 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RealtimeDatabase{T}"/> class.
        /// </summary>
        /// <param name="childQuery"> The child query.  </param>
        /// <param name="elementRoot"> The element Root. </param>
        /// <param name="offlineDatabaseFactory"> The offline database factory.  </param>
        /// <param name="filenameModifier"> Custom string which will get appended to the file name.  </param>
        /// <param name="streamChanges"> Specifies whether changes should be streamed from the server.  </param>
        /// <param name="pullEverythingOnStart"> Specifies if everything should be pull from the online storage on start. It only makes sense when <see cref="streamChanges"/> is set to true. </param>
        /// <param name="pushChanges"> Specifies whether changed items should actually be pushed to the server. If this is false, then Put / Post / Delete will not affect server data. </param>
        public RealtimeDatabase(ChildQuery childQuery, string elementRoot, Func <Type, string, IDictionary <string, OfflineEntry> > offlineDatabaseFactory, string filenameModifier, StreamingOptions streamingOptions, InitialPullStrategy initialPullStrategy, bool pushChanges, ISetHandler <T> setHandler = null)
        {
            this.childQuery          = childQuery;
            this.elementRoot         = elementRoot;
            this.streamingOptions    = streamingOptions;
            this.initialPullStrategy = initialPullStrategy;
            this.pushChanges         = pushChanges;
            this.Database            = offlineDatabaseFactory(typeof(T), filenameModifier);
            this.firebaseCache       = new FirebaseCache <T>(new OfflineCacheAdapter <string, T>(this.Database));
            this.subject             = new Subject <FirebaseEvent <T> >();

            this.PutHandler = setHandler ?? new SetHandler <T>();

            this.isSyncRunning = true;
            Task.Factory.StartNew(this.SynchronizeThread, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default);
        }
        public FirebaseOfflineCacheRepo(
            FirebaseClient client,
            string path,
            string key = "",
            StreamingOptions streaming      = StreamingOptions.None,
            InitialPullStrategy initialPull = InitialPullStrategy.Everything)
        {
            // The offline database filename is named after type T.
            // So, if you have more than one list of type T objects, you need to differentiate it
            // by adding a filename modifier; which is what we're using the "key" parameter for.
            _baseQuery  = client.Child(path);
            _realtimeDb = _baseQuery
                          .AsRealtimeDatabase <T>(key, string.Empty, streaming, initialPull, true);

            SyncExceptionThrown = Observable
                                  .FromEventPattern <ExceptionEventArgs>(
                h => _realtimeDb.SyncExceptionThrown += h,
                h => _realtimeDb.SyncExceptionThrown -= h);
        }
Esempio n. 7
0
        void Execute(StreamingOptions options)
        {
            try
            {
                StreamingEndpoint streamingFilter = new StreamingEndpoint();
                int count = 0;
                foreach (Status status in streamingFilter.GetStreamingStatus(options))
                {
                    System.Diagnostics.Debug.WriteLine(status);
                    count++;

                    if (count == 5)
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Assert.True(false, Util.ExceptionMessage(ex));
            }
        }
Esempio n. 8
0
 public SpeechKitSttStreamClient(Uri address, Options rSpec, ILoggerFactory loggerFactory) : base(address)
 {
     this.sessionConf = new StreamingOptions()
     {
         RecognitionModel = new RecognitionModelOptions()
         {
             Model       = "general",
             AudioFormat = new AudioFormatOptions()
             {
                 ContainerAudio = new ContainerAudio()
                 {
                     ContainerAudioType = rSpec.audioEncoding,
                 }
             },
             TextNormalization = new TextNormalizationOptions()
             {
                 TextNormalization = TextNormalizationOptions.Types.TextNormalization.Enabled,
                 ProfanityFilter   = false
             }
         }
     };
     speechKitRpcClient = new Recognizer.RecognizerClient(MakeChannel(loggerFactory));
 }
        private void startStreaming()
        {
            if (!streamingIsActive)
            {
                StreamingOptions streamingOptions = new StreamingOptions();
                streamingOptions.include_annotations         = true;
                streamingOptions.include_html                = false;
                streamingOptions.include_marker              = true;
                streamingOptions.include_channel_annotations = false;
                streamingOptions.include_message_annotations = true;
                streamingOptions.include_post_annotations    = true;
                streamingOptions.include_user_annotations    = true;

                userStream = new Streaming.UserStream(this.accessToken, streamingOptions);

                IAsyncResult asyncResult = userStream.StartUserStream(
                    streamCallback: streamCallback,
                    unifiedCallback: unifiedCallback,
                    mentionsCallback: mentionsCallback,
                    channelsCallback: channelsCallback,
                    streamStoppedCallback: streamStoppedCallback);

                SubscriptionOptions subscriptionOptions = new SubscriptionOptions();
                subscriptionOptions.include_deleted    = true;
                subscriptionOptions.include_incomplete = false;
                subscriptionOptions.include_muted      = false;
                subscriptionOptions.include_private    = true;
                subscriptionOptions.include_read       = true;

                //userStream.subscribe_to_endpoint(userStream.available_endpoints["Unified"]);
                userStream.subscribe_to_endpoint(userStream.available_endpoints["Stream"]);
                userStream.subscribe_to_endpoint(userStream.available_endpoints["Mentions"]);
                userStream.subscribe_to_endpoint(userStream.available_endpoints["Channels"]);

                streamingIsActive = true;
            }
        }
Esempio n. 10
0
 /// <summary>
 /// Create new instances of the <see cref="RealtimeDatabase{T}"/>.
 /// </summary>
 /// <typeparam name="T"> Type of elements. </typeparam>
 /// <typeparam name="TSetHandler"> Type of the custom <see cref="ISetHandler{T}"/> to use. </typeparam>
 /// <param name="filenameModifier"> Custom string which will get appended to the file name. </param>
 /// <param name="elementRoot"> Optional custom root element of received json items. </param>
 /// <param name="streamingOptions"> Realtime streaming options. </param>
 /// <param name="initialPullStrategy"> Specifies what strategy should be used for initial pulling of server data. </param>
 /// <param name="pushChanges"> Specifies whether changed items should actually be pushed to the server. It this is false, then Put / Post / Delete will not affect server data. </param>
 /// <returns> The <see cref="RealtimeDatabase{T}"/>. </returns>
 public static RealtimeDatabase <T> AsRealtimeDatabase <T, TSetHandler>(this ChildQuery query, string filenameModifier = "", string elementRoot = "", StreamingOptions streamingOptions = StreamingOptions.LatestOnly, InitialPullStrategy initialPullStrategy = InitialPullStrategy.MissingOnly, bool pushChanges = true)
     where T : class
     where TSetHandler : ISetHandler <T>, new()
 {
     return(new RealtimeDatabase <T>(query, elementRoot, query.Client.Options.OfflineDatabaseFactory, filenameModifier, streamingOptions, initialPullStrategy, pushChanges, Activator.CreateInstance <TSetHandler>()));
 }
Esempio n. 11
0
        public IEnumerable <Status> GetStreamingStatus(StreamingOptions options)
        {
            CheckData(options);

            if (!string.IsNullOrWhiteSpace(options.Follow) && !long.TryParse(options.Follow, out long id))
            {
                User data = Task.Run(() => UserData.GetUser(new UserShowOptions {
                    User = options.User, ScreenName = options.Follow
                })).Result;
                options.Follow = data.id_str;
            }

            using (HttpClient httpClient = new HttpClient())
            {
                httpClient.Timeout = TimeSpan.FromMilliseconds(Timeout.Infinite);
                List <KeyValuePair <string, string> > p = new List <KeyValuePair <string, string> >();

                foreach (var item in options.GetParameters())
                {
                    p.Add(item);
                }

                var formUrlEncodedContent = new FormUrlEncodedContent(p);
                formUrlEncodedContent.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");

                EncodeOptions(options);
                HttpRequestMessage request = OAuthHelper.GetRequest(HttpMethod.Post, STATUS_FILTER, options);
                request.Content = formUrlEncodedContent;

                var response = httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead).Result;

                if (!response.IsSuccessStatusCode)
                {
                    using (var reader = new StreamReader(response.Content.ReadAsStreamAsync().Result))
                    {
                        string message = reader.ReadToEnd();
                        if (!string.IsNullOrEmpty(message))
                        {
                            throw new Exception($"{response.StatusCode}:{message}");
                        }
                        else
                        {
                            throw new Exception($"{response.StatusCode}:{response.ReasonPhrase}");
                        }
                    }
                }

                using (StreamReader reader = new StreamReader(response.Content.ReadAsStreamAsync().Result))
                {
                    while (!reader.EndOfStream)
                    {
                        string json = reader.ReadLine();
                        if (!string.IsNullOrWhiteSpace(json))
                        {
                            Status status = Util.Deserialize <Status>(json);
                            if (status != null && !string.IsNullOrEmpty(status.ResolvedText))
                            {
                                yield return(status);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 12
0
 protected void EncodeOptions(StreamingOptions options)
 {
     options.Track  = string.IsNullOrEmpty(options.Track) ? options.Track : Util.EncodeString(WebUtility.HtmlDecode(options.Track));
     options.Follow = string.IsNullOrEmpty(options.Follow) ? options.Follow : Util.EncodeString(WebUtility.HtmlDecode(options.Follow));
 }
Esempio n. 13
0
 public VideoConverter(IOptions <StreamingOptions> opts, ILogger <VideoConverter> log)
 {
     this.opts = opts.Value;
     this.log  = log;
 }
Esempio n. 14
0
 public VideoController(VideoConverter videos, IRtspService api, IOptions <StreamingOptions> opts)
 {
     this.videos = videos;
     this.api    = api;
     this.opts   = opts.Value;
 }
        /// <summary>
        /// Generates the streaming URI for live or pre-recorded streams.
        /// </summary>
        /// <param name="id">The identifier (monitorId if source=live or eventId if source=event).</param>
        /// <param name="source">The streaming source (live or event).</param>
        /// <param name="mode">The streaming mode (video or snapshot).</param>
        /// <param name="options">The streaming options.</param>
        /// <returns>The URI to the specified stream</returns>
        public string GenerateStreamingURI(int id, StreamingOptions.Source source = StreamingOptions.Source.Live, StreamingOptions.Mode mode = StreamingOptions.Mode.MJPEG, StreamingOptions options = null)
        {
            var @params = new Dictionary <string, object>();

            // Set the mode (Snapshot or Video)
            switch (mode)
            {
            case StreamingOptions.Mode.JPEG:     // Snapshot = single
                @params["mode"] = "single";
                break;

            case StreamingOptions.Mode.MJPEG:     // Video = jpeg
                @params["mode"] = "jpeg";
                break;
            }
            // Set the source (live or event)
            switch (source)
            {
            case StreamingOptions.Source.Live:
                @params["monitor"] = id;
                break;

            case StreamingOptions.Source.Event:
                @params["source"] = "event";
                @params["replay"] = "none";
                @params["event"]  = id;
                break;
            }
            // Set the streaming options
            if (options?.Scale > 0)
            {
                @params["scale"] = options.Scale;
            }
            if (options?.Width > 0)
            {
                @params["width"] = options.Width + "px";
            }
            if (options?.Height > 0)
            {
                @params["height"] = options.Height + "px";
            }
            if (options?.Buffer > 0)
            {
                @params["buffer"] = options.Buffer;
            }
            if (options?.MaxFPS > 0)
            {
                @params["maxfps"] = options.MaxFPS;
            }
            if (!string.IsNullOrEmpty(options?.ConnKey))
            {
                @params["connkey"] = options.ConnKey;
            }
            if (options?.IncludeAuthentificationToken ?? true)
            {
                @params["auth"] = this.AuthentificationToken;
            }
            return(((options?.IncludeRootURI ?? false) ? this.RootUri.TrimEnd('/') : "") + "/cgi-bin/nph-zms?" + string.Join("&", @params.Select(v => $"{v.Key}={v.Value}").ToArray()));
        }