Exemplo n.º 1
0
        /// <summary>
        /// duration を、候補の中から「乱数」で選ぶ。
        /// 乱数を使いはするが、「底」を日毎+自分のサービス番号と決めて使い、日が変わる時に再度「底」を宣言する。
        /// </summary>
        /// <returns></returns>
        private List <outputFormatBasic> getDataTimePattern1()
        {
            List <outputFormatBasic> result = new List <outputFormatBasic>();
            Int32  counter          = 0;
            Int32  soundNameCounter = 0;
            Int32  soundKindCounter = 0;
            Int32  genleBig         = 0;
            Int32  genleSmall       = 0;
            string line             = "";
            bool   keepTableFlag    = true;

            Int32[] durationItems    = this.service.madaraDurations;
            Int32   seed             = 0;
            Int32   dayNum           = -1;
            Random  rnd              = null;
            Int32   copyControlValue = 0;

            for (DateTime current = today; current < this.lastDay;)  // 指定した日付「まで」作る
            {
                if (dayNum != current.Day)
                {
                    seed   = makeSeed(this.today, this.service);
                    dayNum = current.Day;
                    rnd    = new Random(seed);
                }
                Int32             duration = durationItems[rnd.Next(durationItems.Count())];
                outputFormatBasic ou       = new outputFormatBasic(
                    service.networkId.value,
                    service,
                    exchangeLetter);
                ou.eventtime      = new epgEventTime(current);
                ou.eventid.value  = ou.eventid.setEventIdFromDate(ou.eventtime.value);
                ou.duration.value = duration;
                //                ou.contents.set("Contents:" + current.ToLongDateString() + "," + current.ToLongTimeString());
                // ou.videoInfo = makeVideoInfoList(ref counter, this.service.madaraResolution); // HDで
                ou.videoInfo = makeVideoInfoList(ref counter, this.service.DefaultVideoComponentType.value);
                ou.audioInfo = makeAudioInfoList(ref ou.service, ref counter, ref soundKindCounter, ref soundNameCounter);

                line          = "";
                keepTableFlag = makeContentsWithAllKanji(ref kanji, ref ou, ref line);
                ou.contents.set(line);
                ou.title.set(makeTitleWithAllKanji(ref kanji));   // "title" + current.ToShortTimeString() , ou.duration.value);
                if (keepTableFlag == false)
                {
                    kanji.setFirst();
                }

                copyControlData cp = new copyControlData(copyControlValue);
                copyControlValue++;
                if (cp.copyControl != null && cp.contents != null)
                {
                    ou.copyControlMain     = cp.copyControl;
                    ou.contentAvailability = cp.contents;
                }

                outputFormatGenle ougenle = new outputFormatGenle();
                ougenle.getGenleNext(ref genleBig, ref genleSmall);
                ougenle.genleBig.value   = genleBig;
                ougenle.genleSmall.value = genleSmall;
                ou.genleInfo.Add(ougenle);
                ou.service = service;

                outputFormatEncoderInfo enc = new outputFormatEncoderInfo();
                enc.rate.value = 6000; // 6Mbps
                ou.encoderInfo = enc;

                result.Add(ou);
                current = current.AddMinutes(duration);
                counter++;
            }
            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="madaraList">startTime, Durationが同一のイベント群へのリンクリスト</param>
        private void setMadara(List <outputFormatBasic> madaraList, List <outputFormatBasic> allList, Int32 count)
        {
/*
 *          if (this.service.madaraType > 0 && IsMadara(this.service.madaraType, madaraList, allList, count) == true)
 *          {
 *              return;
 *          }
 */
            Int32 bitrateBase = 18000 / allList.Count() - 100;

            // 親を探す → madaraList内、サービスIDの最も若いイベント

            Int32             s      = Int32.MaxValue;
            outputFormatBasic parent = null;

            foreach (outputFormatBasic ou in allList)
            {
                if (madaraList.Contains(ou))
                {
                    if (ou.serviceid.value < s)
                    {
                        parent = ou;
                        s      = ou.serviceid.value;
                    }
                }
                else
                {
                    ou.madara = null; // 削除
                }
            }

            // bitrate 調整

#if true // bitrate考えすぎ
            Int32 nonMaedaraBitrate = 0;
            Int32 bitrateUsable     = 18000 - this.calcFixRate(parent.eventtime.value, allList);
            Int32 madaraBitrate     = 0;
            // 残ったbitrateを乱数で割り振る。
            foreach (outputFormatBasic ou in allList)
            {
                //eventTime は一緒だが durationが違う! → まだら以外のbitrateを決める
                if (ou.madara == null)
                {
                    if (ou.service.madaraResolution == "SD") // 残念、SDだった
                    {
                        ou.encoderInfo.rate.value = 6000;    // 6Mbps 固定
                    }
                    else
                    {
                        Int32 rndMax = bitrateUsable;
                        if (bitrateUsable < 4000)
                        {
                            rndMax = 4000;
                        }
                        ou.encoderInfo.rate.value = rnd.Next(4000, rndMax);
                    }
                    nonMaedaraBitrate += ou.encoderInfo.rate.value;
                }
            }
            madaraBitrate = bitrateUsable - nonMaedaraBitrate;
#endif

            // 親は「自分含む全部の EventId,ServiceIdを収集」
            // 子は「親のEventId,ServiceId をメモ」
            List <string> childEventList   = new List <string>();
            List <string> childServiceList = new List <string>();
            foreach (outputFormatBasic p in madaraList)
            {
                if (p == parent)
                {
                    foreach (outputFormatBasic pp in madaraList)
                    {
                        parent.madara.eventIdList.Add(pp.eventid.ToOutput());
                        // parent.madara.serviceList.Add(pp.service.madaraToChNum.ToString());
                        parent.madara.serviceList.Add(pp.service.serviceId.ToOutput());
                    }
                }
                else
                {
                    childEventList.Add(p.eventid.value.ToString("X"));
                    childServiceList.Add(p.service.madaraToChNum.ToString());
                    p.madara.eventIdList.Add(parent.eventid.ToOutput());
                    p.madara.serviceList.Add(parent.service.serviceId.ToOutput());
                }
#if true
                p.encoderInfo.rate.value = madaraBitrate;
#else
                p.encoderInfo.rate.value = bitrateBase * madaraList.Count();
#endif
            }


            foreach (outputFormatBasic p in madaraList)
            {
                string title = this.madaraTitle[rnd.Next(this.madaraTitle.Count())];
                p.title.value    = title; //  "●我はまだらなり●";
                p.contents.value = "Bitrate:" + parent.encoderInfo.rate.value.ToString() + @"kbps\&"
                                   + "プライマリ:" + parent.service.madaraToChNum.ToString()
                                   + "(EventID:" + parent.eventid.value.ToString("X") + @")\&"
                                   + "従属:" + String.Join(@"\,", childServiceList.ToArray())
                                   + "(EventID:" + String.Join(@"\,", childEventList.ToArray()) + @"\&)";
            }
        }