Camera – Stream live video from Android to the RTMP server

I am working on an Android RAT project (Remote Administration Tool) as a course project. I would like to add a live video stream feature to the RAT. I searched for different ways and found three different ways:

  1. Takes videos from the service and then uploads them
  2. Transfers video from the camera to a local web server in an Android application (for example, https://github.com/darshanrn/SpyCam)
  3. Ant Media is just the right solution to encrypt the video and stream it as a live stream (https://github.com/ant-media/LiveVideoBroadcaster).

The problem, however, is that Ant Broadcaster needs an activity to preview the camera. However, as described here (https://github.com/sprimgupta/Secret-Video-Recorder), it is possible to record videos from a service without preview.

I'm wondering how to use Ant Broadcaster to create video streams within services.

Ant Media connects a service to an activity and then sends the video:
https://github.com/ant-media/LiveVideoBroadcaster/blob/master/liveVideoBroadcasterSDK/src/main/java/io/antmedia/android/broadcaster/LiveVideoBroadcaster.java

Conversion of an SQL command into Lambda or Java 8 Stream

I'm starting with Java 8 and want to turn the following SQL command into a lambda function:

SELECT * FROM CorrespondenceCandidate c, (SELECT entityEngine, MAX (m1)
similarityMaxima FROM CorrespondenceCandidata WHERE m1 <> 0 GROUP BY
entityOrig) r WHERE c.entityRequest = r.Request AND AND c.m1 =
r.ÄhnlichkeitMaxima

I created the class Correspondence With getter and setter,

public correspondence

int code;
String name;
String entity;
String EntityDestino;
double m1;
double m2;
twice m3;
double medMax;
double that;


public int getCode () {
Return code;
}
public void setCode (int code) {
this.codigo = code;
}
public String getNome () {
return name;
}
public void setNome (String name) {
this.name = name;
}
public String getEntityOrigem () {
return entityEngine;
}
public void setEntityOrigem (String entityOrigem) {
this.sourceOrigem = SourceType;
}
public String getDataInfo () {
return EntidadeDestino;
}
public void setEntityDestination (String entityDestination) {
EntityDestino = EntityDestino;
}
public double getM1 () {
return m1;
}
public void setM1 (double m1) {
this.m1 = m1;
}
public double getM2 () {
return m2;
}
public void setM2 (double m2) {
this.m2 = m2;
}
public double getM3 () {
return m3;
}
public void setM3 (double m3) {
this.m3 = m3;
}
public double getMedMax () {
return medMax;
}
public void setMedMax (double medMax) {
this.medMax = medMax;
}
public double getDem () {
return that;
}
public void setDem (double dem) {
this.dem = that;
}

Handle stream data with Dataflow

I have a websocket connection with the third-party API. The API returns a lot of data. At peak times, hundreds of messages per second are returned. I have to process the data for two purposes: Store everything in a database and send some data to RabbitMq.

The idea is the following:
I want to store data in the database if the batch size is 1000 or a timeout of 3 seconds.

I want to publish data to RabbitMQ after 1 second. It is a kind of throttling because there is a lot of data. Also, I have to pick the last record for the particular ticker I made in Action block, eg: We have the following records in the batch:

{"Ticker": "MSFT", "DateTime": & # 39; 2019-05-14T10: 00: 00: 100 & # 39;}
{"Ticker": "MSFT", "DateTime": & # 39; 2019-05-14T10: 00: 00: 150 & # 39;}
{"Ticker": "AAPL", "DateTime": & # 39; 2019-05-14T10: 00: 00: 300 & # 39;}

All I have to do is publish the last one for the particular ticker, so after filtering two records will be published:

{"Ticker": "MSFT", "DateTime": & # 39; 2019-05-14T10: 00: 00: 150 & # 39;}
{"Ticker": "AAPL", "DateTime": & # 39; 2019-05-14T10: 00: 00: 300 & # 39;}

Full code:

public class StreamMessagePipeline < T > where T: StreamingMessage {
private read-only BatchBlock < T > _saveBatchBlock;
private read-only BatchBlock < T > _publishBatchBlock;

public StreamMessagePipeline () {
_saveBatchBlock = new BatchBlock < T > (1000);
_publishBatchBlock = new BatchBlock < T > (500);

SetupSaveBatchPipeline ();
SetupPublishBatchPipeline ();
}

private void SetupSaveBatchPipeline () {
var saveBatchTimeOut = TimeSpan.FromSeconds (3);
var saveBatchTimer = new timer (saveBatchTimeOut.TotalMilliseconds);

saveBatchTimer.Elapsed + = (s, e) => _saveBatchBlock.TriggerBatch ();

var actionBlockSave = new ActionBlock <IEnumerable < T >> (x => {
// Reset the timeout because we received a batch
saveBatchTimer.Stop ();
saveBatchTimer.Start ();

Console.WriteLine ($ "Save to DB: {x.Count ()}");
});

_saveBatchBlock.LinkTo (actionBlockSave, new DataflowLinkOptions {
PropagateCompletion = true
});
}

private void SetupPublishBatchPipeline () {
var publishBatchTimeOut = TimeSpan.FromSeconds (1);
var publishBatchTimer = new timer (publishBatchTimeOut.TotalMilliseconds);

publishBatchTimer.Elapsed + = (s, e) => _publishBatchBlock.TriggerBatch ();

var actionBlockPublic = new ActionBlock <IEnumerable < T >> (x => {
varres = x.GroupBy (d => d.Ticker) .Select (d => d.OrderByDescending (s => s.DateTime) .FirstOrDefault ()). ToList ();

Console.WriteLine ($ "Publish data somewhere: {res.Count ()}");
// Reset the timeout because we received a batch
publishBatchTimer.Stop ();
publishBatchTimer.Start ();

});

_publishBatchBlock.LinkTo (actionBlockPublic, new DataflowLinkOptions {
PropagateCompletion = true
});
}

public asynchronous task handle (T record) {
wait _saveBatchBlock.SendAsync (record);
wait _publishBatchBlock.SendAsync (record);
}

}