Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Agnfolie

Pages: [1]
1
Audio / Streaming Sound over UDP
« on: January 26, 2012, 10:12:54 am »
Hello!

I am currently developing a voip like application for my car-puter(minipc in my car). On roadtrips it is nice to be able to speak with the other families we travel with using the car's internal stereo system. I am currently in a state where I can see the info recieved but not hear the sound. I hear some clicking thou! Any ideas to what could be wrong?

Good to know:
I have a UDPSocket(named "Socket") as a global variable to simulate sending between computers.

My Recorder:
Code: [Select]

class NetworkRecorder : public sf::SoundBufferRecorder
{
public:
void setPort(unsigned short outport)
{
port = outport;
}
private:
virtual bool OnProcessSamples(const sf::Int16* samples, std::size_t sampleCount)
{
        //std::cout << "NumSamples: " << sampleCount << " time: " << clock.GetElapsedTime() << std::endl;
packet.Clear();
packet.Append(samples,sampleCount * sizeof(sf::Int16));
sf::Sleep(20);
Socket.Send(packet,"127.0.0.1",port);
return true;
}

//Vars
unsigned short port;
sf::Clock clock;
sf::Packet packet;
};



My Reciever:
Code: [Select]

 class NetworkStreamer : public sf::SoundStream
 {
 public :

     bool Open(unsigned short prt)
     {
         port = prt;
while(Socket.Bind(prt))
{
};
// Initialize the stream -- important!
         Initialize(1, SAMPLECOUNT);
return true;
     }

 private :

     virtual bool OnGetData(Chunk& data)
     {
         //Recieve UDP data and add to stream
sf::Packet packet;
std::cout << "Got Data \n";
Socket.Receive(packet,adr,recieveport);
data.NbSamples = packet.GetDataSize()/sizeof(sf::Int16*);
data.Samples = reinterpret_cast<const sf::Int16*>(packet.GetData());
for(int i = 0;i < data.NbSamples;i+=5)
{
std::cout << data.Samples[i] << "\n";
}
         // Return true to continue playing
         return true;
     }

     virtual void OnSeek(sf::Uint32 timeOffset)
     {
// Allways play the latest recieved
         // Change the current position in the stream source
     }

//Vars
unsigned short port;
sf::UdpSocket Socket;
sf::IpAddress adr;
unsigned short recieveport;

 };


The main parts:
Code: [Select]

void recieveloop(unsigned short port)
{
sf::Clock clock;
NetworkStreamer stream;
stream.Open(port);
stream.Play();
while(1 || clock.GetElapsedTime() < 2000)
{
}
}




int main()
{
unsigned short outport,inport;

outport = 2000;
inport  = 2000;

if (sf::SoundBufferRecorder::IsAvailable())
 {
NetworkRecorder Recorder;
Recorder.Start(SAMPLECOUNT);
Recorder.setPort(outport);
sf::Thread Thread(&recieveloop,inport);
Thread.Launch();
sf::Clock clock;
while( 1 || clock.GetElapsedTime() < 20000)
{
}
Recorder.Stop();



}

return EXIT_SUCCESS;
}


Also another thought:
Is there a way to send the data to multiple IP's or simply out in the air? Seeing as I don't wan't to hardcode the destinations...

2
C / Compiling CSFML for powerpc-603e-linux
« on: December 16, 2011, 03:28:33 pm »
Hello!

I am developing an application for one embedded system in a vehicle. This vehicle needs the ability to communicate with an ethernet buss connecting other embedded systems.

The problem is that this one system is running ubuntu(stripped down to its minimal) and I cannot access it directly. I have to compile the programs on another computer and then flash them over.

The compiler im using is /gcc-3.3.2-glibc-2.3.2/bin/powerpc-603e-linux-gcc
As I am new to makefiles I do not understand how I compile the csfml 1.6 library with this compiler and thus request your help.

3
Network / TCP: Error in msvcp100d.dll
« on: June 27, 2011, 11:23:51 am »
Hello!

*SOLVED*

I am currently developing a program that will recieve frames from a server connected to a webcam. The server seems to be working perfectly by itself. It is running a Asynchronous connect and closes the connection every time it is done sending a frame.

Trobule is in the Client.

Visual Studio C++ 2010
WinXP

Code:
Code: [Select]
#include <SFML\Network.hpp>
#include <stdio.h>
#include <iostream>
#include <opencv\highgui.h>
#include <opencv\cv.h>
#include "stdafx.h"
#define imageHeight_default 480
#define imageWidth_default 640


 
int main()
{

    IplImage  *frame = 0;
    int       key = 0;
int imageWidth = imageWidth_default;
int imageHeight = imageHeight_default;
sf::SocketTCP Client;
size_t Recieved;

if(!Client.Connect(6117," 138.106.152.147"))
{
std::cout << "Error connecting" << std::endl;
}
else
{
char Buffer[921600];
if (Client.Receive(Buffer, sizeof(Buffer), Recieved) != sf::Socket::Done)
{
std::cout << "Error recieving" << std::endl;
Client.Close();
}
else
{
std::cout << "Data recieved correctly" << std::endl;
Client.Close();
}
}
}


And the output on screen:
Error recieving

The break during runtime links me to line 202 in xutility (from c:\program files\microsoft visual studio 10.0\vc\include\xutility)

Any thoughts?
I am quite new to network programming.

*Update*:

I have minimized the code and searched for the place I get the error. It seems to be in the
Code: [Select]
sf::SocketTCP Client;Line
I am baffled since I do the same thing in the server and it works.


*SOLVED*:
Turns out that the error was with the exiting of the program. I used
Code: [Select]
return 1; and got the error whilst
Code: [Select]
exit(1);worked.

Pages: [1]