2

我正在使用 EC4 SP2 SDK 在 c# 中编写应用程序。

我想将我的文件发布到媒体服务器发布点。我搜索并找到了 2 个关于在发布点上设置和身份验证的示例,但要么来自较旧的 sdk,要么不起作用(并且用于控制台)。基本上我的应用程序什么都不编码,就好像它没有什么可编码的。在 deub 模式下,我可以看到源文件和服务器的正确属性。

编码过程需要 0 秒来处理。我检查了服务器事件的日志,并收到警告“安全系统已收到无法解码的身份验证请求”。我只是不知道比这更进一步分手。任何帮助,将不胜感激。

这是一段代码:

 private void broadcastSourceFileToMediaServer2()
    {             
        using (LiveJob job = new LiveJob())
        {
            String filetoencode = @"c:\temp\niceday.wmv";

            LiveFileSource filesource = job.AddFileSource(filetoencode);
            filesource.PlaybackMode = FileSourcePlaybackMode.Loop;
            job.ActivateSource(filesource);
            job.ApplyPreset(LivePresets.VC1Broadband4x3);

            //don't know which one is good to use 
            job.AcquireCredentials += new EventHandler<AcquireCredentialsEventArgs>(job_AcquireCredentials);
            _myUserName = "indes";
            _pw = PullPW("indes");              

            Uri url = new Uri("http://192.168.1.74:8080/live");
            PushBroadcastPublishFormat pubpoint = new PushBroadcastPublishFormat();
            pubpoint.PublishingPoint = url;

            pubpoint.UserName = _myUserName;
            pubpoint.Password = _pw;

            job.PublishFormats.Add(pubpoint);       

            job.PreConnectPublishingPoint();

            job.StartEncoding();
            statusBox.Text = job.NumberOfEncodedSamples.ToString();

            job.StopEncoding();
            job.Dispose();
        }
  }




    public static string _myUserName { get; set; }

    public static SecureString _pw { get; set; }

    //codificação de Password a enviar
    private static SecureString PullPW(string pw)
    {
        SecureString s = new SecureString();
        foreach (char c in pw) s.AppendChar(c);
        return s;
    }

 static void job_AcquireCredentials(object sender, AcquireCredentialsEventArgs e)
    {
        e.UserName = _myUserName;
        e.Password = _pw;
        e.Modes = AcquireCredentialModes.None;
    }
4

4 回答 4

2

进展:

我设法在服务器上进行了身份验证(至少获得了积极的审计事件)。

我从这个改变:

//don't know which one is good to use 
        job.AcquireCredentials += new EventHandler<AcquireCredentialsEventArgs>(job_AcquireCredentials);
        _myUserName = "indes";
        _pw = PullPW("indes");              

        Uri url = new Uri("http://192.168.1.74:8080/live");
        PushBroadcastPublishFormat pubpoint = new PushBroadcastPublishFormat();
        pubpoint.PublishingPoint = url;

        pubpoint.UserName = _myUserName;
        pubpoint.Password = _pw;

对此:

        job.AcquireCredentials += new EventHandler<AcquireCredentialsEventArgs>(job_AcquireCredentials);
        _myUserName = @"mediaservername\user";
        _pw = PullPW("user_password");              

        Uri url = new Uri("http://192.168.1.74:8080/live");
        PushBroadcastPublishFormat pubpoint = new PushBroadcastPublishFormat();
        pubpoint.PublishingPoint = url;

如果您在一侧看到是否必须在用户名之前包含域(域或计算机名)。这改变了服务器上失败的审计事件,所以我可以消除手动凭据 pubpoint.username 和 pubpoint.Password。

现在我只是在处理缺少输出格式的异常。上它。

于 2011-11-12T13:58:15.810 回答
1

使用 SMOOTH Streaming 怎么样,我设法让我的项目继续进行,但除了看下面的部分之外,我没有得到更多,到具有 PUBLISH 开关类型的部分。忽略文件部分

internal bool StartStream()
{
    Busy = true;
    // Instantiates a new job for encoding
    //  

    //***************************************Live Stream Archive******************************
    if (blnRecordFromFile)
    {

        // Sets up publishing format for file archival type
        FileArchivePublishFormat fileOut = new FileArchivePublishFormat();



        //  job.ApplyPreset(LivePresets.VC1512kDSL16x9);

        // Gets timestamp and edits it for filename
        string timeStamp = DateTime.Now.ToString();
        timeStamp = timeStamp.Replace("/", "-");
        timeStamp = timeStamp.Replace(":", ".");

        // Sets file path and name
        string path = "C:\\output\\";
        string filename = "Capture" + timeStamp + ".ismv";
        if (!Directory.Exists(path))
            Directory.CreateDirectory(path);

        fileOut.OutputFileName = Path.Combine(path, filename);

        // Adds the format to the job. You can add additional formats as well such as
        // Publishing streams or broadcasting from a port
        job.PublishFormats.Add(fileOut);

    }
    //******************************END OF Stream PORTION****************************************

    ////////////////////////////////////////////////////////////////////////////////////////////////////
    //*************************************** Process Files or Live Stream******************************
    if (blnRecordFromFile)
    {
        job.ApplyPreset(LivePresets.VC1IISSmoothStreaming720pWidescreen);

        job = new LiveJob();
        // Verifies all information is entered
        if (string.IsNullOrWhiteSpace(sourcePath) || string.IsNullOrWhiteSpace(destinationPath))
            return false;

        job.Status += new EventHandler<EncodeStatusEventArgs>(StreamStatus);

        LiveFileSource fileSource;
        try
        {
            // Sets file to active source and checks if it is valid
            fileSource = job.AddFileSource(sourcePath);
        }
        catch (InvalidMediaFileException)
        {
            return false;
        }

        // Sets to loop media for streaming
        //   fileSource.PlaybackMode = FileSourcePlaybackMode.Loop;

        // Makes this file the active source. Multiple files can be added 
        // and cued to move to each other at their ends
        job.ActivateSource(fileSource);
    }
    //******************************END OF FILE PORTION****************************************


    // Sets up variable for fomat data
    switch (publishType)
    {
        case Output.Archive:
            // Verifies destination path exists and if not creates it
            try
        {
            if (!Directory.Exists(destinationPath))
                Directory.CreateDirectory(destinationPath);
        }
            catch (IOException)
            {
                return false;
            }

            FileArchivePublishFormat archiveFormat = new FileArchivePublishFormat();

            // Gets the location of the old extention and removes it
            string filename = Path.GetFileNameWithoutExtension(sourcePath);

            // Sets the archive path and file name
            archiveFormat.OutputFileName = Path.Combine(destinationPath, filename + ".ismv");
            job.PublishFormats.Add(archiveFormat);
        break;

        case Output.Publish:
            // Setups streaming of media to publishing point 
            job = new LiveJob();

            // Aquires audio and video devices
            Collection<EncoderDevice> devices = EncoderDevices.FindDevices(EncoderDeviceType.Video);
            EncoderDevice video = devices.Count > 0 ? devices[0] : null;
            for (int i = 0; i < devices.Count; ++i)
                //  devices[i].Dispose();
                devices.Clear();

            devices = EncoderDevices.FindDevices(EncoderDeviceType.Audio);
            EncoderDevice audio = devices.Count > 0 ? devices[0] : null;
            for (int i = 1; i < devices.Count; ++i)
                devices[i].Dispose();
            devices.Clear();

            // Checks for a/v devices
            if (video != null && audio != null)
            {


                //job.ApplyPreset(Preset.FromFile(@"C:\Tempura\LivePreset3.xml"));
                job.ApplyPreset(LivePresets.H264IISSmoothStreamingLowBandwidthStandard);
                job.OutputFormat.VideoProfile.SmoothStreaming = true;
                deviceSource = job.AddDeviceSource(video, audio);

                // Make this source the active one
                job.ActivateSource(deviceSource);
            }
            else
            {
                error = true;
            }

            PushBroadcastPublishFormat publishFormat = new PushBroadcastPublishFormat();
            try
        {
            // checks the path for a valid  publishing point
            publishFormat.PublishingPoint = new Uri(destinationPath);

        }
            catch (UriFormatException)
            {
                return false;
            }

            // Adds the publishing format to the job

            try
        {




            // job.ApplyPreset(LivePresets.VC1IISSmoothStreaming480pWidescreen);
            job.PublishFormats.Add(publishFormat);
            job.PreConnectPublishingPoint();
        }
            catch (Exception e)
            {
                MessageBox.Show(e.StackTrace.ToString());
            }

        break;
        default:
        return false;
    }
    job.StartEncoding();

    return true;
}
于 2012-03-07T05:31:29.353 回答
0

我将您的代码更改为以下代码,它似乎运行良好。我猜你的问题是你处理了 LiveJob 类的实例。在完成对整个流的编码之前,您必须保持实例处于活动状态。所以更改使用部分并删除 StopEncoding 和 Dispose 就可以了。

    private void broadcastSourceFileToMediaServer2()
    {
        LiveJob job = new LiveJob();
        String filetoencode = @"c:\temp\niceday.wmv";

        LiveFileSource filesource = job.AddFileSource(filetoencode);
        filesource.PlaybackMode = FileSourcePlaybackMode.Loop;
        job.ActivateSource(filesource);
        job.ApplyPreset(LivePresets.VC1Broadband4x3);

        //don't know which one is good to use 
        job.AcquireCredentials += new EventHandler<AcquireCredentialsEventArgs>(job_AcquireCredentials);
        _myUserName = "indes";
        _pw = PullPW("indes");              

        Uri url = new Uri("http://192.168.1.74:8080/live");
        PushBroadcastPublishFormat pubpoint = new PushBroadcastPublishFormat();
        pubpoint.PublishingPoint = url;

        pubpoint.UserName = _myUserName;
        pubpoint.Password = _pw;

        job.PublishFormats.Add(pubpoint);       

        job.PreConnectPublishingPoint();

        job.StartEncoding();
        statusBox.Text = job.NumberOfEncodedSamples.ToString();
    }

    public static string _myUserName { get; set; }

    public static SecureString _pw { get; set; }

    //codificação de Password a enviar
    private static SecureString PullPW(string pw)
    {
        SecureString s = new SecureString();
        foreach (char c in pw) s.AppendChar(c);
        return s;
    }

    static void job_AcquireCredentials(object sender, AcquireCredentialsEventArgs e)
    {
        e.UserName = _myUserName;
        e.Password = _pw;
        e.Modes = AcquireCredentialModes.None;
    }
于 2012-02-23T10:13:42.613 回答
0

可悲的是,我没有足够的代表发表评论,所以我必须把它写成答案。

由于您正在开始现场工作,因此为了进行流式传输,您不应在 StartEncoding 之后立即调用 job.StopEncoding()。我认为通常你会使用一个事件来停止编码。如果您开始编码并立即停止它,那么您没有或只有非常小的输出是合乎逻辑的。

于 2012-09-11T17:07:44.347 回答