2

I'm coding an application in c# using EC4 SP2 SDK.

I want to publish my file to a media server publishing point. I've searched and found 2 examples regarding seting up and auth on publishing points, but either are from older sdk's or do not work (and are for console). basicly my application doesn't encode nothing, as if it had nothing to encode. When in degub mode checkpont i can see the correct properties for the source file and for the server.

The encoding process takes 0secs to process. I checked the logs on the server events and i get a warning "the security system has received and auth request that could not be decoded". I just havo no knowledge to break up further than this. Any help would be appreciated.

this is the piece of code:

 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 Answers4

2

Progresses:

I managed to authenticate (at least get a positive audit event) on the server.

I changed from this:

//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;

To this:

        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;

If you see on one side if had to include the domain (either domain or computername) before username. this changed the failed audit events on the server, so i could eliminate the manual credentials pubpoint.username and pubpoint.Password.

Now I'm just dealing with a lack of output format exception. On to it.

1

How about using SMOOTH Streaming, I managed to get my project going but I didn't get much more beyond Look below, to the part that has the PUBLISH switch type. ignore the file portion

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;
}
SingerOfTheFall
  • 29,228
  • 8
  • 68
  • 105
Doug
  • 11
  • 1
0

Sadly I dont have enough rep to comment, so I have to write it as an answer.

Due to you are starting a live job, in order to stream you should not call job.StopEncoding() right after StartEncoding. I think usually you would use an event to stop the encoding. If you start encoding and immediately stop it, it is only logical you have no, or only a very small output.

Kevkong
  • 460
  • 3
  • 16
0

I changed your code to the following and it seems work well. I guess your problem is that you disposed the instance of LiveJob class. You have to keep the instance alive before it finished encoding the whole stream. So change the using part and remove the StopEncoding and Dispose will be OK.

    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;
    }
Jason Sturges
  • 15,855
  • 14
  • 59
  • 80