Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty wave file when recording a call #1

Open
Sirpyerre opened this issue Dec 27, 2017 · 0 comments
Open

Empty wave file when recording a call #1

Sirpyerre opened this issue Dec 27, 2017 · 0 comments

Comments

@Sirpyerre
Copy link

When I run the code a empty wave file is created but when finished the applications this file is deleted.
I'm using a modem HIRO V.92 Model: H50113.
This application i will to use for access control the guest to residents in a housing subdivision.
My code is:

 private void OnDial(object sender, EventArgs e)
        {
            TAddress addr = (TAddress) cbAddress.SelectedItem;
            LINEADDRESSTYPES addrType = (LINEADDRESSTYPES) cbDestinationType.SelectedItem;

            TAPIMEDIATYPES mediaType = TAPIMEDIATYPES.AUDIO;
            if (addr.QueryMediaType(TAPIMEDIATYPES.VIDEO))
                mediaType |= TAPIMEDIATYPES.VIDEO;

            try
            {
                addr.Open(mediaType);
            }
            catch (TapiException ex)
            {
                if (ex.ErrorCode == unchecked((int) 0x80040004))
                {
                    try
                    {
                        addr.Open(TAPIMEDIATYPES.DATAMODEM);
                    }
                    catch (Exception exception)
                    {
                        toolStripStatusLabel1.Text = exception.Message;
                    }

                }
                else
                {
                    toolStripStatusLabel1.Text = ex.Message;
                }
                
            }

            currCall = addr.CreateCall(textDestination.Text, addrType, mediaType);
            if (currCall != null)
            {
                try
                {
                    playBackTerminal = currCall.RequestTerminal(
                        TTerminal.FilePlaybackTerminal,
                        TAPIMEDIATYPES.AUDIO, TERMINAL_DIRECTION.TD_CAPTURE
                    );

                    if (playBackTerminal != null)
                    {
                        playBackTerminal.MediaPlayList = new string[] {PLAY_FILENAME};
                    }
                    else
                    {
                        MessageBox.Show("Failed to retrieve playback terminal.");
                    }
                    RecordConversation();
                }
                catch (TapiException ex)
                {
                    MessageBox.Show("On Dial: " + ex.Message);
                }

                try
                {
                    currCall.Connect(false);
                    toolStripStatusLabel1.Text = "Placing call";
                }
                catch (TapiException ex)
                {
                    toolStripStatusLabel1.Text = ex.Message;
                }
            }
        }

        private void RecordConversation()
        {
            if (currCall != null)
            {
                try
                {
                    recordTerminal = currCall.RequestTerminal(
                        TTerminal.FileRecordingTerminal,
                        TAPIMEDIATYPES.MULTITRACK,
                        TERMINAL_DIRECTION.TD_RENDER
                    );

                    if (recordTerminal != null)
                    {
                        recordTerminal.RecordFileName = "PETER-GRABACIÓN.wav";
                        currCall.SelectTerminalOnCall(recordTerminal);
                        recordTerminal.Start();
                    }
                    else
                    {
                        MessageBox.Show("Error al grabar");
                    }
                }
                catch (TapiException ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }

Thank you in avanced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant