public override int GetHashCode()
        {
            int hash = 1;

            if (ResourceName.Length != 0)
            {
                hash ^= ResourceName.GetHashCode();
            }
            if (feedItem_ != null)
            {
                hash ^= FeedItem.GetHashCode();
            }
            if (FeedItemTargetType != 0)
            {
                hash ^= FeedItemTargetType.GetHashCode();
            }
            if (feedItemTargetId_ != null)
            {
                hash ^= FeedItemTargetId.GetHashCode();
            }
            if (Status != 0)
            {
                hash ^= Status.GetHashCode();
            }
            if (targetCase_ == TargetOneofCase.Campaign)
            {
                hash ^= Campaign.GetHashCode();
            }
            if (targetCase_ == TargetOneofCase.AdGroup)
            {
                hash ^= AdGroup.GetHashCode();
            }
            if (targetCase_ == TargetOneofCase.Keyword)
            {
                hash ^= Keyword.GetHashCode();
            }
            if (targetCase_ == TargetOneofCase.GeoTargetConstant)
            {
                hash ^= GeoTargetConstant.GetHashCode();
            }
            if (targetCase_ == TargetOneofCase.Device)
            {
                hash ^= Device.GetHashCode();
            }
            if (targetCase_ == TargetOneofCase.AdSchedule)
            {
                hash ^= AdSchedule.GetHashCode();
            }
            hash ^= (int)targetCase_;
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
        public override int GetHashCode()
        {
            int hash = 1;

            if (ResourceName.Length != 0)
            {
                hash ^= ResourceName.GetHashCode();
            }
            if (HasFeedItem)
            {
                hash ^= FeedItem.GetHashCode();
            }
            if (FeedItemTargetType != global::Google.Ads.GoogleAds.V8.Enums.FeedItemTargetTypeEnum.Types.FeedItemTargetType.Unspecified)
            {
                hash ^= FeedItemTargetType.GetHashCode();
            }
            if (HasFeedItemTargetId)
            {
                hash ^= FeedItemTargetId.GetHashCode();
            }
            if (Status != global::Google.Ads.GoogleAds.V8.Enums.FeedItemTargetStatusEnum.Types.FeedItemTargetStatus.Unspecified)
            {
                hash ^= Status.GetHashCode();
            }
            if (targetCase_ == TargetOneofCase.Campaign)
            {
                hash ^= Campaign.GetHashCode();
            }
            if (targetCase_ == TargetOneofCase.AdGroup)
            {
                hash ^= AdGroup.GetHashCode();
            }
            if (targetCase_ == TargetOneofCase.Keyword)
            {
                hash ^= Keyword.GetHashCode();
            }
            if (targetCase_ == TargetOneofCase.GeoTargetConstant)
            {
                hash ^= GeoTargetConstant.GetHashCode();
            }
            if (targetCase_ == TargetOneofCase.Device)
            {
                hash ^= Device.GetHashCode();
            }
            if (targetCase_ == TargetOneofCase.AdSchedule)
            {
                hash ^= AdSchedule.GetHashCode();
            }
            hash ^= (int)targetCase_;
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
        public void MergeFrom(FeedItemTarget other)
        {
            if (other == null)
            {
                return;
            }
            if (other.ResourceName.Length != 0)
            {
                ResourceName = other.ResourceName;
            }
            if (other.HasFeedItem)
            {
                FeedItem = other.FeedItem;
            }
            if (other.FeedItemTargetType != global::Google.Ads.GoogleAds.V8.Enums.FeedItemTargetTypeEnum.Types.FeedItemTargetType.Unspecified)
            {
                FeedItemTargetType = other.FeedItemTargetType;
            }
            if (other.HasFeedItemTargetId)
            {
                FeedItemTargetId = other.FeedItemTargetId;
            }
            if (other.Status != global::Google.Ads.GoogleAds.V8.Enums.FeedItemTargetStatusEnum.Types.FeedItemTargetStatus.Unspecified)
            {
                Status = other.Status;
            }
            switch (other.TargetCase)
            {
            case TargetOneofCase.Campaign:
                Campaign = other.Campaign;
                break;

            case TargetOneofCase.AdGroup:
                AdGroup = other.AdGroup;
                break;

            case TargetOneofCase.Keyword:
                if (Keyword == null)
                {
                    Keyword = new global::Google.Ads.GoogleAds.V8.Common.KeywordInfo();
                }
                Keyword.MergeFrom(other.Keyword);
                break;

            case TargetOneofCase.GeoTargetConstant:
                GeoTargetConstant = other.GeoTargetConstant;
                break;

            case TargetOneofCase.Device:
                Device = other.Device;
                break;

            case TargetOneofCase.AdSchedule:
                if (AdSchedule == null)
                {
                    AdSchedule = new global::Google.Ads.GoogleAds.V8.Common.AdScheduleInfo();
                }
                AdSchedule.MergeFrom(other.AdSchedule);
                break;
            }

            _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
        }
        private void ScheduleDownloadedHandler(Exception error, AdSchedule schedule)
        {
            System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                if (error != null)
                {
                    HandleManifestDownloadFailed(error);
                    return;
                }

                if (IsLoaded)
                {
                    this.adSchedule = schedule;
                    if (AutoPlay || PlayWhenReady)
                    {
                        try
                        {
                            Status = SchedulingStatus.ScheduleReady;
                        }
                        catch (Exception ex)
                        {
                            Status = SchedulingStatus.Failed;
                            if (SchedulingFailed != null) SchedulingFailed(this, new SchedulingFailedEventArgs(ex));
                        }
                        finally
                        {
                            // release the player block
                            ReleasePlayback();
                        }
                    }
                    else
                    {
                        Status = SchedulingStatus.Postponed;
                    }
                }
                else
                {
                    Status = SchedulingStatus.Disabled;
                }
            });
        }
        void player_ContentChanged(object sender, EventArgs e)
        {
            pendingMediaSource = null;
            PlayWhenReady = false;
            PostRoll = null;
            adSchedule = null;
            CleanupScheduledAds();
            if (player.ActiveMediaPlugin != null)
            {
                Status = SchedulingStatus.Downloading;
                // block the player from starting. We need to get a video manifest first in case there is a preroll.
                BlockPlayback();

                System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    object adData = null;
            // Disable warning on using freewheel and microsoft keys
            #pragma warning disable 618
                    if (player.ContentMetadata.ContainsKey(Key_FreeWheelUrl))
                    {
                        adData = player.ContentMetadata[Key_FreeWheelUrl];
                    }
                    if (player.ContentMetadata.ContainsKey(Key_MicrosoftUrl))
                    {
                        adData = player.ContentMetadata[Key_MicrosoftUrl];
                    }
            #pragma warning restore 618

                    if (player.ContentMetadata.ContainsKey(Key_AdUrl))
                    {
                        adData = player.ContentMetadata[Key_AdUrl];
                    }
                    if (adData != null)
                    {
                        if (adData is String || adData is Stream)
                        {
                            try
                            {
                                if (adData is String)
                                {
                                    string uri = adData as String;
                                    if (Uri.IsWellFormedUriString(uri, UriKind.RelativeOrAbsolute) == false)
                                    {
                                        uri = Uri.EscapeUriString(uri);
                                    }
                                    AdManager.GetSchedule(uri, ScheduleDownloadedHandler);
                                }
                                else if (adData is Stream)
                                {
                                    AdManager.GetSchedule(adData as Stream, ScheduleDownloadedHandler);
                                }
                            }
                            catch (Exception ex)
                            {
                                HandleManifestDownloadFailed(ex);
                            }
                        }
                        else
                        {
                            SendLogEntry("UAC Metadata type is not supported", Microsoft.SilverlightMediaFramework.Plugins.Primitives.LogLevel.Information, "Skipping UAC ad scheduling");
                        }
                    }
                    else
                    {

                        if (AutoPlay || PlayWhenReady)
                            ReleasePlayback();
                        Status = SchedulingStatus.Failed;

                        SendLogEntry("UAC Metadata not found", Microsoft.SilverlightMediaFramework.Plugins.Primitives.LogLevel.Information, "Skipping UAC ad scheduling");
                        return;
                    }
                });
            }
            else
            {
                Status = SchedulingStatus.Disabled;
            }
        }
        private void HandleManifestDownloadFailed(Exception ex)
        {
            adSchedule = null;
            if (AutoPlay || PlayWhenReady)
                ReleasePlayback();

            Status = SchedulingStatus.Failed;

            if (SchedulingFailed != null)
                SchedulingFailed(this, new SchedulingFailedEventArgs(ex));

            SendLogEntry("UAC VideoManifest.DownloadAsync Failed", Microsoft.SilverlightMediaFramework.Plugins.Primitives.LogLevel.Error, ex.Message);
        }
        private IEnumerable<AdPod> GetActiveElements(AdSchedule schedule)
        {
            TimeSpan? startPosition = null;

            if (player.ContentMetadata.ContainsKey(Key_StartPosition))
            {
                object startPositionObject = player.ContentMetadata[Key_StartPosition];
                if (startPositionObject is TimeSpan)
                {
                    startPosition = (TimeSpan)startPositionObject;
                }
                else if (startPositionObject is string)
                {
                    var startPositionString = (string)startPositionObject;
                    TimeSpan startPositionResult;
                    if (TimeSpan.TryParse(startPositionString, out startPositionResult))
                    {
                        startPosition = startPositionResult;
                    }
                }
            }
            if (!startPosition.HasValue)
            {
                startPosition = player.ContentStartPosition;
            }

            IEnumerable<AdPod> pods = schedule.AdPods;
            if (startPosition.HasValue)
            {
                pods = pods.Where(pod => pod.ScheduledTime >= startPosition.Value.Subtract(StartPositionExcludeTheshold));
            }

            return pods;
        }
Exemple #8
0
        public void MergeFrom(FeedItemTarget other)
        {
            if (other == null)
            {
                return;
            }
            if (other.ResourceName.Length != 0)
            {
                ResourceName = other.ResourceName;
            }
            if (other.feedItem_ != null)
            {
                if (feedItem_ == null || other.FeedItem != "")
                {
                    FeedItem = other.FeedItem;
                }
            }
            if (other.FeedItemTargetType != 0)
            {
                FeedItemTargetType = other.FeedItemTargetType;
            }
            if (other.feedItemTargetId_ != null)
            {
                if (feedItemTargetId_ == null || other.FeedItemTargetId != 0L)
                {
                    FeedItemTargetId = other.FeedItemTargetId;
                }
            }
            switch (other.TargetCase)
            {
            case TargetOneofCase.Campaign:
                Campaign = other.Campaign;
                break;

            case TargetOneofCase.AdGroup:
                AdGroup = other.AdGroup;
                break;

            case TargetOneofCase.Keyword:
                if (Keyword == null)
                {
                    Keyword = new global::Google.Ads.GoogleAds.V1.Common.KeywordInfo();
                }
                Keyword.MergeFrom(other.Keyword);
                break;

            case TargetOneofCase.GeoTargetConstant:
                GeoTargetConstant = other.GeoTargetConstant;
                break;

            case TargetOneofCase.Device:
                Device = other.Device;
                break;

            case TargetOneofCase.AdSchedule:
                if (AdSchedule == null)
                {
                    AdSchedule = new global::Google.Ads.GoogleAds.V1.Common.AdScheduleInfo();
                }
                AdSchedule.MergeFrom(other.AdSchedule);
                break;
            }

            _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
        }